Answered

How to find nearby labels?

I =[... 1 1 1 2 3 3 1 1 2 2 3 3 4 4 4 5 5 3 ...

How to find nearby labels?

I =[... 1 1 1 2 3 3 1 1 2 2 3 3 4 4 4 5 5 3 ...

5 hours ago | 0

| accepted

Answered

How to extract column and row index and the corresponding value from a matrix?

A = [0 1 4 7 6 0]; out = sortrows([fullfact(size(A)),A(:)]);

How to extract column and row index and the corresponding value from a matrix?

A = [0 1 4 7 6 0]; out = sortrows([fullfact(size(A)),A(:)]);

2 days ago | 1

Answered

can we check a condition at the end of a loop?

B = sort(repmat(1:8,6,4),2); [m,n] = size(B); for i0 = 1:m while any(~diff(B(i0,:))) B(i0,:) = B(i0,randperm(n))...

can we check a condition at the end of a loop?

B = sort(repmat(1:8,6,4),2); [m,n] = size(B); for i0 = 1:m while any(~diff(B(i0,:))) B(i0,:) = B(i0,randperm(n))...

3 days ago | 0

Answered

Calculating Means for Blocks of Data from Excel

A = [2 1 2 3 5 8 6 9 4 3 2 3 2 1 4 6 7 8 9 6 3 2]; lo = A(:) >= 4; loo = cumsum([0;diff(lo)==1]).*lo; lo3 = loo > 0; out =...

Calculating Means for Blocks of Data from Excel

A = [2 1 2 3 5 8 6 9 4 3 2 3 2 1 4 6 7 8 9 6 3 2]; lo = A(:) >= 4; loo = cumsum([0;diff(lo)==1]).*lo; lo3 = loo > 0; out =...

4 days ago | 0

Answered

How to change 0 to 1 and update a matrix

n = numel(x1); y1 = ~x1; % if MATLAB >= R2016b k = y1.*eye(n); % if MATLAB <= R2016a k = bsxfun(@times,y1,eye(n)); out...

How to change 0 to 1 and update a matrix

n = numel(x1); y1 = ~x1; % if MATLAB >= R2016b k = y1.*eye(n); % if MATLAB <= R2016a k = bsxfun(@times,y1,eye(n)); out...

4 days ago | 0

| accepted

Answered

Sort a list of files

data = { 'dantec7100_Ma=01_wait_1000_ Yaw -10,00° Pitch -10,00°' 'dantec7100_Ma=01_wait_1000_ Yaw -10,00° Pitch -15,00°'...

Sort a list of files

data = { 'dantec7100_Ma=01_wait_1000_ Yaw -10,00° Pitch -10,00°' 'dantec7100_Ma=01_wait_1000_ Yaw -10,00° Pitch -15,00°'...

5 days ago | 0

Answered

Could anyone help me how to shuffle the numbers in each column

[m,n] = size(A); out = zeros(m,n); out([randperm(m) + (0:m-1)*m,randi(m,1,n-m)+m^2]) = A(A~=0);

Could anyone help me how to shuffle the numbers in each column

[m,n] = size(A); out = zeros(m,n); out([randperm(m) + (0:m-1)*m,randi(m,1,n-m)+m^2]) = A(A~=0);

8 days ago | 0

| accepted

Answered

How to compare two matrices of different dimentions and get the result in new column

Bnew = B.*(A == 2000);

How to compare two matrices of different dimentions and get the result in new column

Bnew = B.*(A == 2000);

9 days ago | 0

Answered

Vector operations not working correctly

cvPredictions = pval < epsilon;

Vector operations not working correctly

cvPredictions = pval < epsilon;

10 days ago | 0

| accepted

Answered

Replace numbers into a vector starts at the center? Looking for general format

vec =[0 0 0 0 0 ]; vec1 = [1 1 1]; z = pad(join(string(vec1),''),numel(vec),'both','0'); out = z{:} - '0'

Replace numbers into a vector starts at the center? Looking for general format

vec =[0 0 0 0 0 ]; vec1 = [1 1 1]; z = pad(join(string(vec1),''),numel(vec),'both','0'); out = z{:} - '0'

12 days ago | 1

Answered

How to delete numbers from cell?

a = {'0,31:1.03 SPEED MEASURED 1 [rpm]' '0,31:1.04 MOTOR SPEED [rpm]' '0,31:1.08 MOTOR TORQUE [%]' '0,31:25.04 T...

How to delete numbers from cell?

a = {'0,31:1.03 SPEED MEASURED 1 [rpm]' '0,31:1.04 MOTOR SPEED [rpm]' '0,31:1.08 MOTOR TORQUE [%]' '0,31:25.04 T...

13 days ago | 1

Answered

sort 2 matrices for minimum numbers sum and divide them

m = 3; r = [ 1 3 4 5 30]; x = [ 5 8 9 4 78]; out = funt(r,x,3); function out = funt(r,x,m) ad = nan(mod(-numel(r),m),...

sort 2 matrices for minimum numbers sum and divide them

m = 3; r = [ 1 3 4 5 30]; x = [ 5 8 9 4 78]; out = funt(r,x,3); function out = funt(r,x,m) ad = nan(mod(-numel(r),m),...

22 days ago | 1

Answered

How to reshape and reorder a 5D arrays to 4D arrays?

Let A - your 5D array: k = size(A); out = zeros(k(1:end-1).*[1,1,2,1]); out(:,:,1:2:end,:) = A(:,:,:,:,1); out(:,:,2:2:end,:...

How to reshape and reorder a 5D arrays to 4D arrays?

Let A - your 5D array: k = size(A); out = zeros(k(1:end-1).*[1,1,2,1]); out(:,:,1:2:end,:) = A(:,:,:,:,1); out(:,:,2:2:end,:...

22 days ago | 0

| accepted

Answered

Finding a range in an array

Let A - your array. Anew = A.*(1 - 2*(A >= 20 & A <= 26.5));

Finding a range in an array

Let A - your array. Anew = A.*(1 - 2*(A >= 20 & A <= 26.5));

30 days ago | 0

Answered

How do I compute impulse response?

You can use the filter function with the coefficients as an input argument.

How do I compute impulse response?

You can use the filter function with the coefficients as an input argument.

1 month ago | 0

| accepted

Answered

How to convert 3 hourly data into a 6 hourly data?

In R2016b [m,n,k] = size(A); t = hours(0:3:(k-1)*3); Ar = reshape(A,m,[]); TT = table2timetable(array2table(Ar),'RowTime',t(...

How to convert 3 hourly data into a 6 hourly data?

In R2016b [m,n,k] = size(A); t = hours(0:3:(k-1)*3); Ar = reshape(A,m,[]); TT = table2timetable(array2table(Ar),'RowTime',t(...

1 month ago | 1

| accepted

Answered

Divide large size matrixes, multiply the small matrixes and sum the results together.

C = sum(A.*B,'all') for MATLAB < R2018b : AB = A.*B; C = sum(AB(:));

Divide large size matrixes, multiply the small matrixes and sum the results together.

C = sum(A.*B,'all') for MATLAB < R2018b : AB = A.*B; C = sum(AB(:));

1 month ago | 0

Answered

creating a large matrix with a pattern

out = kron(eye(200),[1;1;0;1]); or a = [1;1;0;1;zeros(796,1)]; out = a(mod((1:800)'-(1:4:800),800)+1);

creating a large matrix with a pattern

out = kron(eye(200),[1;1;0;1]); or a = [1;1;0;1;zeros(796,1)]; out = a(mod((1:800)'-(1:4:800),800)+1);

1 month ago | 1

Answered

Select random data from a matrix and replace it

A = [1 0 1 0 1 1 1 1 0 0 0 0 0 0 0 1 1 1 1 1 1 1 0 0 1 0 0 0 0 0]; p = 4; [ii,jj] = find(A); jjj = accumarray(ii,jj,...

Select random data from a matrix and replace it

A = [1 0 1 0 1 1 1 1 0 0 0 0 0 0 0 1 1 1 1 1 1 1 0 0 1 0 0 0 0 0]; p = 4; [ii,jj] = find(A); jjj = accumarray(ii,jj,...

1 month ago | 0

| accepted

Answered

Unable to use a value of type 'cell' as an index.

Use: md = cat(1,m{:}); ... mar1 = eo (md(1,1))^ (eo - 1);

Unable to use a value of type 'cell' as an index.

Use: md = cat(1,m{:}); ... mar1 = eo (md(1,1))^ (eo - 1);

1 month ago | 0

| accepted

Answered

How to convert row and column data into x,y,flag format?

out = [fullfact(size(BW1)),BW1(:)];

How to convert row and column data into x,y,flag format?

out = [fullfact(size(BW1)),BW1(:)];

1 month ago | 1

Answered

filling a matrix with a loop

out = full(spdiags(ones(400,3),[0,1,3],400,400));

filling a matrix with a loop

out = full(spdiags(ones(400,3),[0,1,3],400,400));

1 month ago | 0

Answered

How to apply a cell array of function handles to an array of double

In your case: out = array_double.*(2:2:6)'; General case: out = arrayfun(@(x,y)cell_array_fuction_handles{x}(y),... ...

How to apply a cell array of function handles to an array of double

In your case: out = array_double.*(2:2:6)'; General case: out = arrayfun(@(x,y)cell_array_fuction_handles{x}(y),... ...

1 month ago | 0

| accepted

Answered

Create a matrix with random integers between 1 and 9

[~,ii] = sort(rand(9,1)); out = reshape(ii,3,3);

Create a matrix with random integers between 1 and 9

[~,ii] = sort(rand(9,1)); out = reshape(ii,3,3);

1 month ago | 0

Answered

Multiplication of 2 3d matrices

FactorRetPf = nansum(TotWeightsPf.*NormClassRetPf,3)'; FactorRetBM = nansum(TotWeightsBM.*NormClassRetBM,3)';

Multiplication of 2 3d matrices

FactorRetPf = nansum(TotWeightsPf.*NormClassRetPf,3)'; FactorRetBM = nansum(TotWeightsBM.*NormClassRetBM,3)';

1 month ago | 1

Answered

How to delete the duplicate number or using unique in the cell?

A={[3];[6 8 3];[5];[10 5]}; k = repelem((1:numel(A))',cellfun(@numel,A)); B = cell2mat(cellfun(@(x)x(:),A,'un',0)); [a,b] =...

How to delete the duplicate number or using unique in the cell?

A={[3];[6 8 3];[5];[10 5]}; k = repelem((1:numel(A))',cellfun(@numel,A)); B = cell2mat(cellfun(@(x)x(:),A,'un',0)); [a,b] =...

1 month ago | 0

| accepted

Answered

vectorization of symmetrical matrix with off-diagonal vectors multiplied with 2

k = 2; o = ones(size(H)); Hl = H.*(tril(o,-1)*(k-1) + 1); out = Hl(tril(o)>0); or e = H.*((k-1)*(1-eye(size(H))) + 1); o...

vectorization of symmetrical matrix with off-diagonal vectors multiplied with 2

k = 2; o = ones(size(H)); Hl = H.*(tril(o,-1)*(k-1) + 1); out = Hl(tril(o)>0); or e = H.*((k-1)*(1-eye(size(H))) + 1); o...

1 month ago | 0

| accepted

Answered

How to get the corresponding logic value based on the sum of vector elements

A = [1,1,2,3,5]; my_input = 5; out = []; n = numel(A); ii = 1:n; for jj = 1:n k = nchoosek(ii,jj); r = sum(resh...

How to get the corresponding logic value based on the sum of vector elements

A = [1,1,2,3,5]; my_input = 5; out = []; n = numel(A); ii = 1:n; for jj = 1:n k = nchoosek(ii,jj); r = sum(resh...

1 month ago | 0

| accepted

Answered

How to find out the impact of independents variables on dependent variable?

Let A - array of your data (365 x 5) : evapotranspiration, temperature, solar radiation, relative humidity and wind speed c = c...

How to find out the impact of independents variables on dependent variable?

Let A - array of your data (365 x 5) : evapotranspiration, temperature, solar radiation, relative humidity and wind speed c = c...

1 month ago | 0

Answered

Search all elements from from array A in array B and write it workspace

Output = A(ismember(A,B))

Search all elements from from array A in array B and write it workspace

Output = A(ismember(A,B))

1 month ago | 0