Answered
Shifting values in a matrix, Alignment of two matrices
[~,ib] = sortrows(B,[2 1]); [~,ia] = sortrows(A,[2 1]); [~,ia2] = sort(ia); D = [A(:,1),B(ib(ia2),1)];

10 years ago | 0

Answered
Find array elements that meet a condition an put them in a secondary array
t = A > .5; [m,n,~] = size(A); [ii,jj] = find(t); B = [ii,rem(jj-1,n)+1,ceil(jj/n),A(t)];

10 years ago | 0

Answered
2D Matrix Operation
t = accumarray(A(:,2),A(:,1),[],@min); out = sortrows([t(t>0),unique(A(:,2))]);

10 years ago | 0

Answered
I don't untersantd the following error:
syms a b c f =(-3-a-b)^2 + ( -1.89-a-b*exp(0.5*c) )^2 + (-1.03 - a- b*exp(c))^2 ... + (-0.36-a-b*exp(1.5*c))^2 + (0.16-...

10 years ago | 1

Answered
Creating Matrix using two vectors and scalar
function out = fun1(r,c,ii) out = ones(numel(c),1)*r; out(:,ii) = c; end use r = [2 7 3 5]; c = [2...

10 years ago | 1

Answered
How can I store my data into a 2D array?
out = reshape(cellstr(dec2bin(abs(x))),size(x));

10 years ago | 0

Answered
Cumsum range and values
cumsum(A).*(A ~= 0) or A = [1 1 1 2 3 4 5 1 2 1 5 4 1 0 0 ...

10 years ago | 0

Answered
how to extract two 2D arrays into one 1D array?
reshape([A, B]',1,[]);

10 years ago | 0

Answered
Hi i want to know if i have a specific numbers like (5 9 11) and i want to distribute them randomly on array which i know it's size , How can i do that?
k = [5 9 11]; ii = randi([1,3],10,6); % [10,6] - size of your array out = k(ii);

10 years ago | 0

Answered
How can I generate a binary matrix of permutations
n = 2; m = 4; ii = nchoosek(1:m,n); k = size(ii,1); out = zeros(k,m); out(sub2ind([k,m],(1:k)'*ones(1,n),ii)) =...

10 years ago | 1

| accepted

Answered
How do I find the number of occurrences of data points between specific values in a matrix?
data = [1 2 2 2 2 2 2 2 2 2 3 1 2 2 2 2 7 8 3 8 3 4 5 6 1 2 2 2 ... 2 2 2 2 2 2 2 2 3 4 1 2 2 2 2 2]; x = [1 3]; ...

10 years ago | 0

| accepted

Answered
How do I find the number of occurrences of data points between specified values in a matrix?
t = x == 1; out = diff(find(t))-1;

10 years ago | 0

| accepted

Answered
How to find the in-between value from a array to get corresponding value from 360*2 matrix
out = interp1(array(:,1),array(:,2),178.4)

10 years ago | 0

| accepted

Answered
Finding Of Same Values in Matrix
a - your array; b = unique(a); [~,idx] = ismember(a,b);

10 years ago | 0

Answered
How to get a 2D data array of complex a+bi number from phase only 2D array.
phase1 = 2*(rand(10)-.5)*pi; % your 2D array of phase values. out = exp(1i*phase1);

10 years ago | 0

Answered
Why is my for loop not working?
y = zeros(3,1); for x = 1:3 y(x) = pi/x; end or without loop x = 1:3; y = pi./x;

10 years ago | 0

| accepted

Answered
how to count non breaking ones from matrix?
t = [true(1,2);diff(A)~=0]; [m,n]=size(A); [~,jj] = ndgrid(1:m,1:n); ii = A.*cumsum(t.*A); b = accumarray([ii(:)+1...

10 years ago | 0

Answered
how can i solve this angle between vectors?
<https://en.wikipedia.org/wiki/Law_of_cosines Law of cosines> a = 3; b = 5; c = 7; % c = a - b alpha = acos((...

10 years ago | 1

Answered
Max Value of Certain Row in Cell Array?
a = cell2mat(yourcellarray); out = max(a(4,:));

10 years ago | 0

| accepted

Answered
Sort cell array based on 2 columns with date and time (strings)
[~,ii] = sort(datenum(strcat(cellname(:,3),{' '},cellname(:,4)))); out = cellname(ii,:);

10 years ago | 2

| accepted

Answered
Create a Matrix with a specific main diagonal
d = randi(35,5,1); out = ~eye(5) + diag(d);

10 years ago | 0

Answered
Locate array element within limits given by another array
a=[3.45 8.99 10.02]; b=[1.03 3.03 5.03 7.03 9.03 11.03 13.03]; [~,~,out] = histcounts(a,b);

10 years ago | 0

Answered
How to store a vector under a for loop
v = 5.8; u = 1/v; Psph = [509.35 507.06 504.77 398.20 394.19 389.61 268.71 266.99 265.85]; r1= 6731; r2= 6731; ...

10 years ago | 0

Answered
Replace elements of a cell
testcell={'R1(2)' 'R1(1)' 'R1(0)'}; vfinal = cell(4,10); vfinal(1,1:3) = testcell

10 years ago | 0

| accepted

Answered
Change an element in diagonal of matrix
e.g.: A=magic(5); ii = diag(true(4,1),-1); A(ii) = 100;

10 years ago | 0

Answered
Delete rows that contains []
x = {[ ] 1 NaN [ ] 1 NaN [ ] 1 NaN [ ] 1 NaN [ ] 1 0 'o_c' 1 1 'w_c' 1 1}; out = x(~...

10 years ago | 0

| accepted

Answered
How to convert from cell array to multidimensional array?
A -your cell array [3 x 3]. Z = cellfun(@(x)reshape(x,1,1,[]),A,'un',0); out = cell2mat(Z);

10 years ago | 1

| accepted

Answered
finding the row number of a matrix
[log1,idxb] = ismember(A,B,'rows');

10 years ago | 1

| accepted

Answered
Convert 1D array to 2D array with x and y coordinates supplied as individual vectors
Data2D = accumarray([row(:),col(:)],data(:),[],[],nan);

10 years ago | 0

| accepted

Answered
Finding the averages for a unique value.
|a| - your array [ii,jj] = ndgrid(a(:,1),1:5); out = [unique(a(:,1)), accumarray([ii(:),jj(:)],reshape(a(:,2:end),[],1),...

10 years ago | 0

Load more