Answered
N-D matrix accumarray
A = randi(10,3,4,2,7); x1 = [2 1 2 3]; x2 = [3 3 2 1 3 2 4]; s = size(A); [a,b,c,d] = ndgrid(1:s(1),x1,1:s...

9 years ago | 1

Answered
How do we count non-zero entries in every column in a table?
Let T - your table: x = [0 0 193 0 0 0 37 0; 53 0 0 0 0 0 0 0; 0 161 0 0 0 0 0 0; 0 0 47 160 0 0 6 15; 0 186 98...

9 years ago | 0

| accepted

Answered
Evaluating a matrix at different time steps
R2016b and later N = 3; w = 0.2; k = 1:N; k = reshape(k,1,1,1,[]); jj = (1:N)'; n = 1:N; t = ...

9 years ago | 0

Answered
I can not create a matrix
BNdog =[23;107;108;23;107;108]; YON_BLNM =[23;107;108]; ri=[0;124.5383;0;32.2448;0;43.2158]; Z =[186.6933;354.4481;11...

9 years ago | 1

| accepted

Answered
I can not create a matrix.
K = [107 719.689 7969.933; 108 342.246 8404.180;23 638.765 8351.331]; KSNKOORD = [8351.311 638.790]; blnmynokta = 23; ...

9 years ago | 1

| accepted

Answered
Adding a new variable called 'Count', which Indexes or counts the occurrence of each stock_code based on their dates
let T - your table. [~,~,ii] = unique(T.symbol); s = accumarray(ii,1); idx = cumsum(s); c = ones(idx(end),1); c...

9 years ago | 1

| accepted

Answered
How to sort a Matrix
p = 4; data = [P.Cost]'; [~,ii] = sort(data); out = P(ii(1:p));

9 years ago | 0

| accepted

Answered
how to stack monthly(hist)
[~,~,c] = xlsread('stack_monthly.xlsx'); [y,m] = datevec(c,'yyyy-mm-ddTHH:MM:SS.FFFZ'); a = unique([y,m],'rows'); out...

9 years ago | 1

| accepted

Answered
Merging and overwiting vectors
Y = B; Y(1:numel(A)) = A;

9 years ago | 0

| accepted

Answered
Expression or statement is incorrect--possibly unbalanced (, {, or [.
small example: newer: [~,a] = yourfunc(vars); old: [a,a] = yourfunc(vars);

9 years ago | 0

Answered
vectorization of for loop code
nn = 1:n; z = temp*(nn.^alpha - (nn - 1).^alpha); prod1 = tril(toeplitz(z));

9 years ago | 2

Answered
How to make FOR loop for this following program.
c = 3*10^8; % speed of light lambda = 1.55*10^-6; % wavelength omega = 2*pi*c/lambda; %angular frequency nrx = 1.5276...

9 years ago | 0

| accepted

Answered
How can I obtain all possible combinations of given values in vector ?
>> V = [1:2]; out = flip(fullfact(flip(V+1))-1,2) out = 0 0 0 1 0 2 1 0 ...

9 years ago | 1

Answered
How to return the row number of the first numerical data?
out = find(~isnan(yourvector),1,'first');

9 years ago | 1

| accepted

Answered
How can I effectively integrate a function in Matlab?
Small example for using: V = @(x) 2*x+2; R = @(x) x.^2; F = @(A,x) x./A-3; I = @(A,x) V(x)*R(x)*F(A,x); ...

9 years ago | 0

Answered
How to create a new matrix adding vectors of different size based on time
*[EDIT]* Let your data - A (cell array): A = {[ 730486.000 0.500 730486.007 NaN 730486.014 0.700 730486...

9 years ago | 1

Answered
insert matrix index to specific number
my small contribution index = [1 6 10]; value = [4 6]; ii = zeros(index(end),1); ii([1,index(2:end-1)+1]) = 1;...

9 years ago | 1

Answered
Combine If statement and for loop?!
delta_x = x(:)+sign(x(:)).*sqrt(r^2./(1+gradient1(:).^2)); delta_y = gradient1(:).*delta_x; We use |gradient1| instead ...

9 years ago | 0

Answered
Splitting a large vector into smaller ones of random size
out = mat2cell(index(:)',1,diff([find([true;diff(index(:)) > 1]);numel(index)+1])');

9 years ago | 2

Answered
How do I get the for loop to run correctly?
out = A*10.^(size(A,2)-1:-1:0)'; % in your case other *[EDIT]* n = floor(log10(A(:,2:end)))+1; n = [n, zeros(size(A...

9 years ago | 1

| accepted

Answered
How to vectorize this loop ?
first a = zeros(fina,fina + nf); ii = init:fina; a(sub2ind([fina,fina + nf], ii,ii + nf)) = b(ii).*c(ii); second ...

9 years ago | 0

| accepted

Answered
How do you turn a 30x30x24 matrix into a 24x900 matrix?
reshape(yourmatrix,[],size(yourmatrix,3))' or reshape(permute(yourmatrix,[2 1 3]),[],size(yourmatrix,3))'

9 years ago | 0

Answered
Creating a matrix from lat, long and z and interpolating missing values
d=[10.5 7.4 11.4 10.7 8.3 12.9 10.8 7.7 14.2 10.6 7.9 3.4 10.1 6.2 5.7 10.7 7.9 4.6] [a1,~,c1] = unique(...

9 years ago | 0

Answered
Sum over all diagonals in lower matrix
P = sum(spdiags(A.',0:size(A,1)-1)).';

9 years ago | 0

Answered
Finding the time difference between two vectors
Let A (cell 80 x 1) and B(cell 3 x 1) your vectors A1 = datenum(A); B1 = datenum(B); out = bsxfun(@minus,A1(:),B1(:)....

9 years ago | 0

| accepted

Answered
Substituing values of a matrix
out = reshape(V(A,2),size(A));

9 years ago | 0

| accepted

Answered
add values in arrays with positive and zero values
a=[1 2 3 3 3]; b=[0 0 1 0 2]; c = a + cumsum(b);

9 years ago | 2

| accepted

Answered
Index exceeds matrix dimensions.
L = sym('L',[1,11]); Xi = sym('Xi',[1,6]); BGx = L.'*Xi; or in your case BGx = sym('L1')*sym('Xi',[1,6]);

9 years ago | 0

| accepted

Answered
how to find minimum number in array other than 0 and 1 ?
out = min(A(~ismember(A,0:1))); or out = min(setdiff(A,0:1)); or out = min(A( A ~= 0 & A ~= 1 ));

9 years ago | 1

| accepted

Answered
corr2 each row
result = corr(A,B);

9 years ago | 0

| accepted

Load more