Answered

How does Matrix(3002:2001:1999998)=0.4 works?

[ii,jj] = ind2sub([1000,2000],3002:2001:1999998); A = sparse(ii,jj,.4,1000,2000);

How does Matrix(3002:2001:1999998)=0.4 works?

[ii,jj] = ind2sub([1000,2000],3002:2001:1999998); A = sparse(ii,jj,.4,1000,2000);

2 hours ago | 0

Answered

Matrix problem with my vectors

theta = (-5:5:25)';%+ n = numel(theta); N = [-0.906 1.43 2.78 4.20 5.03 5.28 -2.49 0.889 4.16 7.71 11.0 7.30 12.7]*4.45; FN_c...

Matrix problem with my vectors

theta = (-5:5:25)';%+ n = numel(theta); N = [-0.906 1.43 2.78 4.20 5.03 5.28 -2.49 0.889 4.16 7.71 11.0 7.30 12.7]*4.45; FN_c...

18 hours ago | 0

Answered

How to subtract a number from a previous one

x = [1;.75;.5;.6]; n = filter(1,[1;1],x); or out = tril(toeplitz(x))*(-1).^(2:numel(x)+1).'; or n = x; for jj = 2:numel(...

How to subtract a number from a previous one

x = [1;.75;.5;.6]; n = filter(1,[1;1],x); or out = tril(toeplitz(x))*(-1).^(2:numel(x)+1).'; or n = x; for jj = 2:numel(...

22 hours ago | 2

| accepted

Answered

how to adjust the conv filtered data same like origanal data?

con=conv(h,L,'same');

how to adjust the conv filtered data same like origanal data?

con=conv(h,L,'same');

23 hours ago | 0

| accepted

Answered

how to count the number of element in observation and make summation?

K = B.TotalRevenue.*ones(size(B,1),3)/3; [a1,~,c1] = unique(B{:,1:3}); out = table(a1,accumarray(c1,K(:)),'v',{'opals','Revenu...

how to count the number of element in observation and make summation?

K = B.TotalRevenue.*ones(size(B,1),3)/3; [a1,~,c1] = unique(B{:,1:3}); out = table(a1,accumarray(c1,K(:)),'v',{'opals','Revenu...

24 hours ago | 0

| accepted

Answered

Create This Matrix to N-Value

n = 3; out = flip(fullfact([n, n]),2) - 1; or [x,y] = ndgrid(0:n-1); out = [y(:),x(:)];

Create This Matrix to N-Value

n = 3; out = flip(fullfact([n, n]),2) - 1; or [x,y] = ndgrid(0:n-1); out = [y(:),x(:)];

3 days ago | 0

| accepted

Answered

How to extend/add elements to an array?

A = [2 3 4 5 0 1 4 5 5 0 3 4 0 2 0 ]; B = [3 2 3 5]; out = A(sort([find(A),repelem(find(A == 0),B)]));

How to extend/add elements to an array?

A = [2 3 4 5 0 1 4 5 5 0 3 4 0 2 0 ]; B = [3 2 3 5]; out = A(sort([find(A),repelem(find(A == 0),B)]));

3 days ago | 0

| accepted

Answered

sort a matrix depending on first row

out = sortrows(B.',1).' variant [~,inx]=sort(B(1,:)); out = B(:,inx);

sort a matrix depending on first row

out = sortrows(B.',1).' variant [~,inx]=sort(B(1,:)); out = B(:,inx);

8 days ago | 10

Answered

comparison of the datasets

T = readtable('example.xlsx','sheet',1); T2 = readtable('example.xlsx','sheet',2); R12 = unique([T2.R1;T2.R2+eps(1e3)]); C = ...

comparison of the datasets

T = readtable('example.xlsx','sheet',1); T2 = readtable('example.xlsx','sheet',2); R12 = unique([T2.R1;T2.R2+eps(1e3)]); C = ...

9 days ago | 0

| accepted

Answered

Data manipulation problem?

d = fopen('Data.csv'); c = textscan(d,'%s','delimiter','\n'); fclose(d); c=c{:}; x = regexp(c,'\-?\d+(\.\d+)?([Ee][+-]...

Data manipulation problem?

d = fopen('Data.csv'); c = textscan(d,'%s','delimiter','\n'); fclose(d); c=c{:}; x = regexp(c,'\-?\d+(\.\d+)?([Ee][+-]...

16 days ago | 0

Answered

Average over duplicate values in xlsx file

T = readtable('yourfile.xlsx'); T_out1 = varfun(@(x)x(1),T,'I',1:14,'G','StimuliName'); T_out2 = varfun(@mean,T,'I',15:18,'G...

Average over duplicate values in xlsx file

T = readtable('yourfile.xlsx'); T_out1 = varfun(@(x)x(1),T,'I',1:14,'G','StimuliName'); T_out2 = varfun(@mean,T,'I',15:18,'G...

16 days ago | 0

Answered

how to Interpolate hourly data

T = readtable('test.txt','ReadVariableNames',false,... 'Format','%d %d %d %f %f %f %f %f'); time1 =...

how to Interpolate hourly data

T = readtable('test.txt','ReadVariableNames',false,... 'Format','%d %d %d %f %f %f %f %f'); time1 =...

18 days ago | 1

| accepted

Answered

How to obtain sum over coalition?

Variant for your new data from example.mat (B). BB = B{:,1:2}; abc = unique(BB(:)); n = numel(abc); C = cell(n,1); for ii =...

How to obtain sum over coalition?

Variant for your new data from example.mat (B). BB = B{:,1:2}; abc = unique(BB(:)); n = numel(abc); C = cell(n,1); for ii =...

18 days ago | 1

Answered

The meaning of a length command

It's length of vector 'w'. >> w = 1.1:.01:1.9; >> length(w) ans = 81 >>

The meaning of a length command

It's length of vector 'w'. >> w = 1.1:.01:1.9; >> length(w) ans = 81 >>

19 days ago | 0

| accepted

Answered

How to separate a vector into positive and negative vectors using a for loop?

x = [-3.6 10 3 -1 11.4 0 7 -9.5 2 15 -1 3]; y = strings(numel(x),1); for ii = 1:length(x) if x(ii) >= 0 y(ii) =...

How to separate a vector into positive and negative vectors using a for loop?

x = [-3.6 10 3 -1 11.4 0 7 -9.5 2 15 -1 3]; y = strings(numel(x),1); for ii = 1:length(x) if x(ii) >= 0 y(ii) =...

19 days ago | 0

Answered

How to form a for-loop to: find the onset (first element) of trials of zeros, ones and twos, in an array of sequences of zeros, ones and twos

n = numel(E); count1 = 1; start_of_trial = [1;zeros(n-1,1)]; trial_value = zeros(n,1); for ii = 2:n if E(ii) - E(ii-1) ...

How to form a for-loop to: find the onset (first element) of trials of zeros, ones and twos, in an array of sequences of zeros, ones and twos

n = numel(E); count1 = 1; start_of_trial = [1;zeros(n-1,1)]; trial_value = zeros(n,1); for ii = 2:n if E(ii) - E(ii-1) ...

19 days ago | 0

| accepted

Answered

How to seasonalise daily weather classification and precipitation data

Where KNG01date_d? date1 = datetime(KNG01date_d,'ConvertFrom','datenum'); TT = array2timetable(KNG01rain_d,'RowTimes',date1...

How to seasonalise daily weather classification and precipitation data

Where KNG01date_d? date1 = datetime(KNG01date_d,'ConvertFrom','datenum'); TT = array2timetable(KNG01rain_d,'RowTimes',date1...

19 days ago | 0

Answered

How to use a for-loop to find the onset (first element) of trials of zeros, ones and twos, in an array of sequences of zeros, ones and twos

function [start_of_trial, trial_value] = find_onsets(E) start_of_trial = find([1;diff(E(:))~= 0]); trial_value = E(sta...

How to use a for-loop to find the onset (first element) of trials of zeros, ones and twos, in an array of sequences of zeros, ones and twos

function [start_of_trial, trial_value] = find_onsets(E) start_of_trial = find([1;diff(E(:))~= 0]); trial_value = E(sta...

19 days ago | 2

Answered

Substracting the value of upper row from all the values from the subsequent rows individually ?

A =[ 2130.18 2217.22 2334.24 2433.29]; out = A(2:end) - A(1);

Substracting the value of upper row from all the values from the subsequent rows individually ?

A =[ 2130.18 2217.22 2334.24 2433.29]; out = A(2:end) - A(1);

19 days ago | 0

Answered

how to select the highest values form each column and set the other values to zero.

[m,n] = size(A); [~,ii] = sort(A); A(bsxfun(@plus,ii(1:end-2,:),(0:n-1)*m)) = 0; or [m,n] = size(A); [~,ii] = sort(A); A(i...

how to select the highest values form each column and set the other values to zero.

[m,n] = size(A); [~,ii] = sort(A); A(bsxfun(@plus,ii(1:end-2,:),(0:n-1)*m)) = 0; or [m,n] = size(A); [~,ii] = sort(A); A(i...

20 days ago | 0

| accepted

Answered

How replace NaN's in a 3d field with the nearest value in the same column?

B = reshape(T,[],1); lo = ~isnan(T); ii = find(lo); C = interp1(ii,B(lo),(1:numel(B))','previous'); T_out = reshape(C,size(T...

How replace NaN's in a 3d field with the nearest value in the same column?

B = reshape(T,[],1); lo = ~isnan(T); ii = find(lo); C = interp1(ii,B(lo),(1:numel(B))','previous'); T_out = reshape(C,size(T...

21 days ago | 0

| accepted

Answered

How to obtain sum over coalition?

s = string(('a':'d')'); ss = s([1 ,2;2,3;2,4;1,4]); v = [20,10,15,10]'; C = cell(4,1); for ii = 1:4 k = num2cell(nchoos...

How to obtain sum over coalition?

s = string(('a':'d')'); ss = s([1 ,2;2,3;2,4;1,4]); v = [20,10,15,10]'; C = cell(4,1); for ii = 1:4 k = num2cell(nchoos...

21 days ago | 0

| accepted

Answered

select data from different data sets

dat1 = [2015 12 10.44 371 4.32 2015 12 11.45 289 3.25 2019 38 16.56 456 1.78]; dat2=[2015 12 10.44 385 1.35 2015 12 11.89 ...

select data from different data sets

dat1 = [2015 12 10.44 371 4.32 2015 12 11.45 289 3.25 2019 38 16.56 456 1.78]; dat2=[2015 12 10.44 385 1.35 2015 12 11.89 ...

21 days ago | 0

Answered

matlab error operands to the || and & & operators must be convertible to logical scalar values

Thanks Walter! My typo. Use P((P< DA.Pl) | (P > DA.Ph)) = 0; instead if (P< DA.Pl) | (P > DA.Ph) P=0; end

matlab error operands to the || and & & operators must be convertible to logical scalar values

Thanks Walter! My typo. Use P((P< DA.Pl) | (P > DA.Ph)) = 0; instead if (P< DA.Pl) | (P > DA.Ph) P=0; end

21 days ago | 0

Answered

How can i know what is the n when the nth is the smallest or biggest

[minvalue, n] = min(A);

How can i know what is the n when the nth is the smallest or biggest

[minvalue, n] = min(A);

21 days ago | 0

Answered

matlab error operands to the || and & & operators must be convertible to logical scalar values

Use P(P< DA.Pl) | (P > DA.Ph) = 0; instead if (P< DA.Pl) | (P > DA.Ph) P=0; end

matlab error operands to the || and & & operators must be convertible to logical scalar values

Use P(P< DA.Pl) | (P > DA.Ph) = 0; instead if (P< DA.Pl) | (P > DA.Ph) P=0; end

21 days ago | 0

Answered

How to select only specific files from a folder that match a list of names stored in a cell and store in a separate folder?

mkdir('new_subfolder'); save('new_subfolder/newfile.mat','C');

How to select only specific files from a folder that match a list of names stored in a cell and store in a separate folder?

mkdir('new_subfolder'); save('new_subfolder/newfile.mat','C');

21 days ago | 0

Answered

Unfold 3D Matrix to 2D

Third variant : A = reshape(1:9,3,[])' + cat(3,0,20,30); [m,n,k] = size(A); size_2_3 = [n,k]; xy0 = [2,3]; out = A(:,FunB...

Unfold 3D Matrix to 2D

Third variant : A = reshape(1:9,3,[])' + cat(3,0,20,30); [m,n,k] = size(A); size_2_3 = [n,k]; xy0 = [2,3]; out = A(:,FunB...

22 days ago | 0

Answered

How to select only specific files from a folder that match a list of names stored in a cell and store in a separate folder?

% Let A - list of 400 names as cell-array(400 x 1) files = string(A) + '.mat'; n = numel(files); C = struct; for ii = 1:n ...

How to select only specific files from a folder that match a list of names stored in a cell and store in a separate folder?

% Let A - list of 400 names as cell-array(400 x 1) files = string(A) + '.mat'; n = numel(files); C = struct; for ii = 1:n ...

22 days ago | 0

| accepted

Answered

Find columns of a Matrix (n x m) that fit best to a Vector (n x 1)

% Let A - your array (24 x 365) % B - your forecast vector (24 x 1) m = 6; ii = sqrt(sum((A - B).^2)); [~,ij] = mink(ii,m)...

Find columns of a Matrix (n x m) that fit best to a Vector (n x 1)

% Let A - your array (24 x 365) % B - your forecast vector (24 x 1) m = 6; ii = sqrt(sum((A - B).^2)); [~,ij] = mink(ii,m)...

22 days ago | 1