Answered

Sum individual elements of rows that have identical elements in other rows

A = [19980227 0.100000000000000 0.0675470000000000 13.7500000000000 0.0704000000000000 0.000100000000000000 -0.001300000000000...

Sum individual elements of rows that have identical elements in other rows

A = [19980227 0.100000000000000 0.0675470000000000 13.7500000000000 0.0704000000000000 0.000100000000000000 -0.001300000000000...

1 day ago | 0

| accepted

Answered

How to plot intergratoion results into a table

out = table(tt,arrayfun(@(t0)100 - integral(@(tt)8*exp(-.1*tt),0,t0),tt),'v',{'Time','data'});

How to plot intergratoion results into a table

out = table(tt,arrayfun(@(t0)100 - integral(@(tt)8*exp(-.1*tt),0,t0),tt),'v',{'Time','data'});

1 day ago | 0

Answered

Numerical Sorting of Cell Matrix by Single Column

A = { 'Wt0,4_Bw8,3_Bt0,4_Ah15_Aa0' '158.6' '9653.1008' '11' 'Wt0,4_Bw8,3_Bt0,4_Ah15_Aa10' '158.6' ...

Numerical Sorting of Cell Matrix by Single Column

A = { 'Wt0,4_Bw8,3_Bt0,4_Ah15_Aa0' '158.6' '9653.1008' '11' 'Wt0,4_Bw8,3_Bt0,4_Ah15_Aa10' '158.6' ...

1 day ago | 2

| accepted

Answered

how to convert data from minute to hourly average

dir1 = 'path_to_folder_with_your_txt_files'; f = dir(fullfile(dir1,'iisc*.txt')); nm = {f.name}'; dt = datetime(regex...

how to convert data from minute to hourly average

dir1 = 'path_to_folder_with_your_txt_files'; f = dir(fullfile(dir1,'iisc*.txt')); nm = {f.name}'; dt = datetime(regex...

1 day ago | 1

| accepted

Answered

Convert a symbolic vector to a list of scalar outputs for a function created by matlabFunction

n = 5; c = sym('c',[n,1]); jacf= matlabFunction(jacobian(prod(c)),'v',{c}); use >> c = 1:5; >> jacf(c(:))...

Convert a symbolic vector to a list of scalar outputs for a function created by matlabFunction

n = 5; c = sym('c',[n,1]); jacf= matlabFunction(jacobian(prod(c)),'v',{c}); use >> c = 1:5; >> jacf(c(:))...

1 day ago | 1

| accepted

Answered

Flip a vector using for

out = flip(yourvector); with loop (no use) out = zeros(size(yourvector)); k = 1; for ii = numel(yourvector):-1:1...

Flip a vector using for

out = flip(yourvector); with loop (no use) out = zeros(size(yourvector)); k = 1; for ii = numel(yourvector):-1:1...

2 days ago | 0

Answered

how can i take average of matrices in a cell?

A - your cell array one variant [m,n,k] = size(A{1}); [h,l] = size(A); A1 = reshape(cat(3,A{:}),m,n,k,h,l); out...

how can i take average of matrices in a cell?

A - your cell array one variant [m,n,k] = size(A{1}); [h,l] = size(A); A1 = reshape(cat(3,A{:}),m,n,k,h,l); out...

2 days ago | 0

| accepted

Answered

How to normalize a matrix of dimension 450×40

|A| - your array Amin = min(A(:)); out = (A - Amin) / (max(A(:)) - Amin);

How to normalize a matrix of dimension 450×40

|A| - your array Amin = min(A(:)); out = (A - Amin) / (max(A(:)) - Amin);

2 days ago | 0

Answered

Mean calculation from nxm matrices using nxm index matlab

out = [(1:12)',accumarray(Month_data(:),flow_data(:),[],@mean)];

Mean calculation from nxm matrices using nxm index matlab

out = [(1:12)',accumarray(Month_data(:),flow_data(:),[],@mean)];

2 days ago | 0

Answered

How to find max value from set of data which changes in sign. For example I have the following data. h=[ 1 2 3 6 8 -7 -6 -9 -2 9 7 6 5 2 -4 -2 -5]. My ans should be 8 (max value in 1st positive set), -9(min value in the 1st negative set), 9, -5 .....

out = accumarray(cumsum(diff([~h(1);h(:) > 0]) ~= 0),h(:),[],@(x)max(abs(x))*sign(x(1)));

How to find max value from set of data which changes in sign. For example I have the following data. h=[ 1 2 3 6 8 -7 -6 -9 -2 9 7 6 5 2 -4 -2 -5]. My ans should be 8 (max value in 1st positive set), -9(min value in the 1st negative set), 9, -5 .....

out = accumarray(cumsum(diff([~h(1);h(:) > 0]) ~= 0),h(:),[],@(x)max(abs(x))*sign(x(1)));

5 days ago | 0

Answered

Non-loop comparison of 3 - D matrices using "find"?

Let A - your 3-D matrix with size that is 21 x 751 x 1500 B - your "flag" array with size that is 1 x 751 x 1500 for |MA...

Non-loop comparison of 3 - D matrices using "find"?

Let A - your 3-D matrix with size that is 21 x 751 x 1500 B - your "flag" array with size that is 1 x 751 x 1500 for |MA...

5 days ago | 0

Answered

How to place NaN at diagonal position in cell array?

a={[],-1,-1,0.8,-0.7,[],[]; [],[],0.9,1,[],-0.9,0.6; -1,[],[],0.9,0.2,[],0.8}; [m,n] = size(a); z = sort([repmat(...

How to place NaN at diagonal position in cell array?

a={[],-1,-1,0.8,-0.7,[],[]; [],[],0.9,1,[],-0.9,0.6; -1,[],[],0.9,0.2,[],0.8}; [m,n] = size(a); z = sort([repmat(...

11 days ago | 0

| accepted

Answered

comparing elements of a cell array based on another cell array

a1 = {[2,5];[1,3,4]}; a2= {[1,4],[1,5],5,4,[3,5,2]}; n = numel(a1); out = cell(n,1); nn = cellfun(@numel,a2); ...

comparing elements of a cell array based on another cell array

a1 = {[2,5];[1,3,4]}; a2= {[1,4],[1,5],5,4,[3,5,2]}; n = numel(a1); out = cell(n,1); nn = cellfun(@numel,a2); ...

11 days ago | 0

| accepted

Answered

how to implement the following table contents in N-dimensional lookup table?

function out = Error_status(Psi,Te,Sector) [T,S,ps] = ndgrid([1, 0, -1],1:6,0:1); x(:,:,1) = string( {'110' '...

how to implement the following table contents in N-dimensional lookup table?

function out = Error_status(Psi,Te,Sector) [T,S,ps] = ndgrid([1, 0, -1],1:6,0:1); x(:,:,1) = string( {'110' '...

11 days ago | 1

Answered

How to display my outputs which one of them is complex numbers and other ones are just 2 digit number in a vertical form side by side. one is "output" and the other ones is "rows" and "columns" in matlab

lo = imag(A) ~= 0; output = A(lo); [rows,cols] = find(lo); out = table(output,rows,cols);

How to display my outputs which one of them is complex numbers and other ones are just 2 digit number in a vertical form side by side. one is "output" and the other ones is "rows" and "columns" in matlab

lo = imag(A) ~= 0; output = A(lo); [rows,cols] = find(lo); out = table(output,rows,cols);

11 days ago | 0

| accepted

Answered

Attempt to reference field of non-structure array.

Maybe this? x=2; D=[1 0 1 0]; X=[1;x;x.^2;x.^3]; dx=D*X; gx=1+x+x.^3;

Attempt to reference field of non-structure array.

Maybe this? x=2; D=[1 0 1 0]; X=[1;x;x.^2;x.^3]; dx=D*X; gx=1+x+x.^3;

11 days ago | 0

Answered

Reshape matrix in the desired form

a = [1 2 3 4] ; b = [5 6 7 8] ; B = [repmat(a,1,4);repelem(b,4)]; or reshape(permute(A,[2,1,3]),[],2)';

Reshape matrix in the desired form

a = [1 2 3 4] ; b = [5 6 7 8] ; B = [repmat(a,1,4);repelem(b,4)]; or reshape(permute(A,[2,1,3]),[],2)';

14 days ago | 0

Answered

How can I skip some rows in Matlab ?

out = You_array(1:2:end,:);

How can I skip some rows in Matlab ?

out = You_array(1:2:end,:);

14 days ago | 1

| accepted

Answered

Parsing a data set into multiple arrays based on value?

a = randi(10000,20,1); % Let a - your array lo = a >= 1000; ii = cumsum(diff([0;lo(:)]) == 1); out = accumarray(i...

Parsing a data set into multiple arrays based on value?

a = randi(10000,20,1); % Let a - your array lo = a >= 1000; ii = cumsum(diff([0;lo(:)]) == 1); out = accumarray(i...

15 days ago | 0

| accepted

Answered

How to process a large matrix of size 28x28x11684?

Just: z = sort(a); With loop: k = size(a,3); z = a; for ii = 1:k z(:,:,ii) = sort(a(:,:,ii)); end

How to process a large matrix of size 28x28x11684?

Just: z = sort(a); With loop: k = size(a,3); z = a; for ii = 1:k z(:,:,ii) = sort(a(:,:,ii)); end

15 days ago | 0

| accepted

Answered

How can I vectorize this function with nested FOR loop?

% MATLAB >= R2016b z = - 20 * exp( - 0.2 * sqrt( .5 * sum( x(:).^2 + y(:)'.^2 ) ) ); % MATLAB <= R2016a [...

How can I vectorize this function with nested FOR loop?

% MATLAB >= R2016b z = - 20 * exp( - 0.2 * sqrt( .5 * sum( x(:).^2 + y(:)'.^2 ) ) ); % MATLAB <= R2016a [...

15 days ago | 2

| accepted

Answered

How to get values in an 8x8x4096 matrix?

Let M - your array [8x8x4096]. One variant: [m,n,k] = size(M); x = [1,2,2]; y = [2,2,1]; out = M(sub2ind([m...

How to get values in an 8x8x4096 matrix?

Let M - your array [8x8x4096]. One variant: [m,n,k] = size(M); x = [1,2,2]; y = [2,2,1]; out = M(sub2ind([m...

16 days ago | 0

| accepted

Answered

Finding neighbour values average of the 2d data set

x1 = floor(x(:))+1; [ii,g] = findgroups(x1); out = [g,splitapply(@mean,y(:),ii)]; Second variant of the output. ...

Finding neighbour values average of the 2d data set

x1 = floor(x(:))+1; [ii,g] = findgroups(x1); out = [g,splitapply(@mean,y(:),ii)]; Second variant of the output. ...

16 days ago | 1

| accepted

Answered

Hi, I would like create a vector using a for loop.

n = 7; P = 1e3; X = P * 1e-3.^(0:n);

Hi, I would like create a vector using a for loop.

n = 7; P = 1e3; X = P * 1e-3.^(0:n);

16 days ago | 1

Answered

Converting 2D matrix to 3D matrix

out = reshape(your_matrix,size_of_your_new_3D_matrix)

Converting 2D matrix to 3D matrix

out = reshape(your_matrix,size_of_your_new_3D_matrix)

17 days ago | 0

| accepted

Answered

Why am I getting an error that matrices must agree?

prompt= 'State the Area: '; Area = input(prompt); prompt= 'State the Straight Cost: '; StrCo = input(prompt); prom...

Why am I getting an error that matrices must agree?

prompt= 'State the Area: '; Area = input(prompt); prompt= 'State the Straight Cost: '; StrCo = input(prompt); prom...

17 days ago | 1

Answered

Search matrix for array of values and place results into another

t = ismember(A',B); Ct = C'; ii = sort(t,'descend'); out = double(ii); out(ii) = Ct(t); out(~ii) = -1; out =...

Search matrix for array of values and place results into another

t = ismember(A',B); Ct = C'; ii = sort(t,'descend'); out = double(ii); out(ii) = Ct(t); out(~ii) = -1; out =...

17 days ago | 0

Answered

How can I calculate Centriod from a sets of location coordinate value(x,y)?

xy_centroid = mean([X,Y]) or >> T = readtable('your_xls_file.xls'); >> XY_centroid = mean(T{:,:}) XY_centroid = ...

How can I calculate Centriod from a sets of location coordinate value(x,y)?

xy_centroid = mean([X,Y]) or >> T = readtable('your_xls_file.xls'); >> XY_centroid = mean(T{:,:}) XY_centroid = ...

17 days ago | 0

| accepted

Answered

Dynamically adding elements into an array every nth element based on user-defined inputs, while preserving array order

S = 1:7; % original sequence ir = 2 ; % insert every "#" times io = 9999; ...

Dynamically adding elements into an array every nth element based on user-defined inputs, while preserving array order

S = 1:7; % original sequence ir = 2 ; % insert every "#" times io = 9999; ...

18 days ago | 1

Answered

If Loop for specific condition

t = -5:0.5:50; tt = [-inf,10,20,30,inf]; f = {@(t)11*t.^2 - 5*t; @(t)1100-5*t; @(t)50*t + 2*(t-20).^2; ...

If Loop for specific condition

t = -5:0.5:50; tt = [-inf,10,20,30,inf]; f = {@(t)11*t.^2 - 5*t; @(t)1100-5*t; @(t)50*t + 2*(t-20).^2; ...

18 days ago | 1