Answered

find row with certain value and put in cell

z = B.*permute(A,[1,3,2]); [~,jj] = ndgrid(1:size(A,1)*2,1:size(A,2)); out = accumarray(jj(:),z(:),[],@(x){unique(x(x~=0))});

find row with certain value and put in cell

z = B.*permute(A,[1,3,2]); [~,jj] = ndgrid(1:size(A,1)*2,1:size(A,2)); out = accumarray(jj(:),z(:),[],@(x){unique(x(x~=0))});

etwa 8 Stunden ago | 0

Answered

How can I equate all values of one vector to another and get the value ? Please find the example below

dataA = [-496,-636,-52,175,-84,-248,-555,-423,34,-174]'; dataB = [-0.399609375000000,-0.512402343750000,-0.0418945312500000,......

How can I equate all values of one vector to another and get the value ? Please find the example below

dataA = [-496,-636,-52,175,-84,-248,-555,-423,34,-174]'; dataB = [-0.399609375000000,-0.512402343750000,-0.0418945312500000,......

etwa 8 Stunden ago | 0

| accepted

Answered

How to generate all pairwise differences between two vectors

out = (a(:)' - b(:))./b(:)*100;

How to generate all pairwise differences between two vectors

out = (a(:)' - b(:))./b(:)*100;

3 Tage ago | 0

Answered

How to find first non repeated (unique) character in a string?

z = 'hello'; [a,~,c] = unique(z,'stable'); out = a(find(accumarray(c,1) == 1,1));

How to find first non repeated (unique) character in a string?

z = 'hello'; [a,~,c] = unique(z,'stable'); out = a(find(accumarray(c,1) == 1,1));

4 Tage ago | 1

Answered

extract the 16 elements (4 by 4 matrix) from a big matrix

n = 4; s = size(A,1); out = reshape(A',s,n,[]); Here: out(:,:,1) -> B, out(:,:,2) -> C, out(:,:,3) -> D and etc.

extract the 16 elements (4 by 4 matrix) from a big matrix

n = 4; s = size(A,1); out = reshape(A',s,n,[]); Here: out(:,:,1) -> B, out(:,:,2) -> C, out(:,:,3) -> D and etc.

6 Tage ago | 0

Answered

how to check symmetric for vector or array with 1 dimension

isequal(A(:),flip(A(:)));

how to check symmetric for vector or array with 1 dimension

isequal(A(:),flip(A(:)));

7 Tage ago | 0

Answered

How to compare each element of a matrix with a number? And then star it out

a = [1 2 3 4 5 6 7]'; c = 6; lo = a >= c; z = ["","*"]'; out = a + z(lo+1);

How to compare each element of a matrix with a number? And then star it out

a = [1 2 3 4 5 6 7]'; c = 6; lo = a >= c; z = ["","*"]'; out = a + z(lo+1);

11 Tage ago | 1

Answered

How to generate all pairwise differences between two vectors

out = a(:) - b(:)';

How to generate all pairwise differences between two vectors

out = a(:) - b(:)';

12 Tage ago | 1

Answered

Find common elements between two vectors and extract data from matrix (vectorized)

A3 = fix(A2.*(10.^-floor(log10(A2)))); [ii,~] = find(squeeze(all(A3==reshape(B,1,1,[])))); [~,~,c] = unique(ii,'stable'); jj ...

Find common elements between two vectors and extract data from matrix (vectorized)

A3 = fix(A2.*(10.^-floor(log10(A2)))); [ii,~] = find(squeeze(all(A3==reshape(B,1,1,[])))); [~,~,c] = unique(ii,'stable'); jj ...

14 Tage ago | 0

| accepted

Answered

Matrix manipulation (matrix A to B format)

AA = [A,repmat([1,0],size(A,1),1)]; A3 = reshape(kron(AA,[1;1]),[],2,2); A3(2:2:end,:,:) = flip(A3(2:2:end,:,:),2).*[-1,1]; B...

Matrix manipulation (matrix A to B format)

AA = [A,repmat([1,0],size(A,1),1)]; A3 = reshape(kron(AA,[1;1]),[],2,2); A3(2:2:end,:,:) = flip(A3(2:2:end,:,:),2).*[-1,1]; B...

14 Tage ago | 1

| accepted

Answered

Program that separates even and odd numbers and shows them in two vectors.

n = (1:100)'; lo = rem(n,2)==1; pares = n(~lo); impares = n(lo);

Program that separates even and odd numbers and shows them in two vectors.

n = (1:100)'; lo = rem(n,2)==1; pares = n(~lo); impares = n(lo);

14 Tage ago | 1

| accepted

Answered

how to detect index of the max amplitude?

[out,ii] = max(A); out_ind = index(ii);

how to detect index of the max amplitude?

[out,ii] = max(A); out_ind = index(ii);

17 Tage ago | 1

| accepted

Answered

how to create this vector?

X=[0 0 0 1 1 1 1 0 0 1 1 0 0 0 1 1 1 1]; Y=[3 6 5]; Y2 = [0,Y]; out = Y2(bwlabel(X) + 1);

how to create this vector?

X=[0 0 0 1 1 1 1 0 0 1 1 0 0 0 1 1 1 1]; Y=[3 6 5]; Y2 = [0,Y]; out = Y2(bwlabel(X) + 1);

19 Tage ago | 1

| accepted

Answered

Scatter data interpolation of a column matrix

T = readtable('torque.xlsx','ReadV',0); torquei = xlsread('torquei.xlsx'); throttle= [0 2.5 5 10 15 20 30 40 50 60 65 70 75 80...

Scatter data interpolation of a column matrix

T = readtable('torque.xlsx','ReadV',0); torquei = xlsread('torquei.xlsx'); throttle= [0 2.5 5 10 15 20 30 40 50 60 65 70 75 80...

19 Tage ago | 0

| accepted

Answered

extract elements from four matrices and create new matrix

Let A,B,C,D - your matrix (4 x 4). out = reshepe(permute(cat(3,A,B,C,D),[3,1,2]),2,2,[]); or out = reshepe(permute(cat(3,A,B,...

extract elements from four matrices and create new matrix

Let A,B,C,D - your matrix (4 x 4). out = reshepe(permute(cat(3,A,B,C,D),[3,1,2]),2,2,[]); or out = reshepe(permute(cat(3,A,B,...

20 Tage ago | 0

Answered

Replace elements of a matrix

A = [1 4 3; 2 3 2;4 2 1;10,7,1]; b = [4 ,10 3 , 15 2 ,20 1 , 30]; [lo,ii] = ismember(A,b(:,1)); A(lo) = b(ii(lo),2); ...

Replace elements of a matrix

A = [1 4 3; 2 3 2;4 2 1;10,7,1]; b = [4 ,10 3 , 15 2 ,20 1 , 30]; [lo,ii] = ismember(A,b(:,1)); A(lo) = b(ii(lo),2); ...

20 Tage ago | 2

| accepted

Answered

How to linearly change values in matrix

toeplitz(1:-.1:.6) or 1 - abs((1:5) - (1:5)')*.1

How to linearly change values in matrix

toeplitz(1:-.1:.6) or 1 - abs((1:5) - (1:5)')*.1

21 Tage ago | 0

| accepted

Answered

How to merge a datetime array with a table

out = table2timetable(Result,'RowTimes',DT);

How to merge a datetime array with a table

out = table2timetable(Result,'RowTimes',DT);

23 Tage ago | 0

| accepted

Answered

Element wise multiplication array-matrix between each element of the array with the whole matrix

result = kron(A(:),B)

Element wise multiplication array-matrix between each element of the array with the whole matrix

result = kron(A(:),B)

23 Tage ago | 1

| accepted

Answered

How to chang matrix size 81x81x30 to 81x81x32 by add row

daily_avg_u(:,:,end + (1:2)) = zeros([size(daily_avg_u(:,:,1)),2]);

How to chang matrix size 81x81x30 to 81x81x32 by add row

daily_avg_u(:,:,end + (1:2)) = zeros([size(daily_avg_u(:,:,1)),2]);

23 Tage ago | 1

| accepted

Answered

Averaging and summing parts of a column based on date

T = readtable('Matlab question.xlsx','Ra','A2:B109','ReadV',0); out = rowfun(@tempfun,T,'G','Var1',... 'OutputV',... ...

Averaging and summing parts of a column based on date

T = readtable('Matlab question.xlsx','Ra','A2:B109','ReadV',0); out = rowfun(@tempfun,T,'G','Var1',... 'OutputV',... ...

24 Tage ago | 0

Answered

I have a 18x3 timetable and i want to get the average of G and T columns from 1-9 and 10-18 then put them in a new table 2x3 but i don't know how to do it

out = varfun(@mean,e,'G','DATE_UTC');

I have a 18x3 timetable and i want to get the average of G and T columns from 1-9 and 10-18 then put them in a new table 2x3 but i don't know how to do it

out = varfun(@mean,e,'G','DATE_UTC');

25 Tage ago | 0

| accepted

Answered

I am getting error in integrating a function from 0 to infinity wrt x. Kindly help.

Try q = integral(fun,0,Inf,'ArrayValued',1); but in your case the result is a zero vector, due to value of the gamma = 0.

I am getting error in integrating a function from 0 to infinity wrt x. Kindly help.

Try q = integral(fun,0,Inf,'ArrayValued',1); but in your case the result is a zero vector, due to value of the gamma = 0.

26 Tage ago | 0

| accepted

Answered

grouped average in arrays

Old MATLAB T = table(A(:),repelem(string(['a':'d','b']'),[3,3,2,3,1]),'v',{'A','B'}); outT = varfun(@mean,T,'G',2);

grouped average in arrays

Old MATLAB T = table(A(:),repelem(string(['a':'d','b']'),[3,3,2,3,1]),'v',{'A','B'}); outT = varfun(@mean,T,'G',2);

26 Tage ago | 0

Answered

Sum specific rows of an array

A = [0.2 2 3 1 3 4 1 4 6 0.8 4 6 2 5 1 1 6 2 0.4 6 2]; [a,~,c] = uniq...

Sum specific rows of an array

A = [0.2 2 3 1 3 4 1 4 6 0.8 4 6 2 5 1 1 6 2 0.4 6 2]; [a,~,c] = uniq...

26 Tage ago | 0

| accepted

Answered

comparing columns in matlab

out = A(all(A(:,1:2:end) ~= A(:,2:2:end),2),:)

comparing columns in matlab

out = A(all(A(:,1:2:end) ~= A(:,2:2:end),2),:)

26 Tage ago | 1

| accepted

Answered

find array in cell using cellfun

A = {[1,2,4],[2,3,4],[1,2,5]}; mes_in=[12,18,15,14,13]; B=[1 2;... 2 1;... 1 4;... 4 1;... 1 5;... 5...

find array in cell using cellfun

A = {[1,2,4],[2,3,4],[1,2,5]}; mes_in=[12,18,15,14,13]; B=[1 2;... 2 1;... 1 4;... 4 1;... 1 5;... 5...

26 Tage ago | 0

| accepted

Answered

Mean calculations in a for-loop

EDIT Let A is your vector with length n = 3192. i1 = 217; ii = 240; B = A; n = numel(A); lo = isnan(A); B(lo) = 0; p =...

Mean calculations in a for-loop

EDIT Let A is your vector with length n = 3192. i1 = 217; ii = 240; B = A; n = numel(A); lo = isnan(A); B(lo) = 0; p =...

27 Tage ago | 0

Answered

Creating a matrix which has particular order of element ?

m = 6; n = 6; lo = triu(~rem((1:n)' + (1:m),2)); out = int64(lo); out(lo) = 1:nnz(lo); out = out'; with kron m = 7; n ...

Creating a matrix which has particular order of element ?

m = 6; n = 6; lo = triu(~rem((1:n)' + (1:m),2)); out = int64(lo); out(lo) = 1:nnz(lo); out = out'; with kron m = 7; n ...

29 Tage ago | 0

| accepted