Answered

How to concentrate matrices of different row length (same column length) into one matrix by unfolding each of the matrices to the smallest row length conatining numbers not nan

M = struct2cell(H); n = min(cellfun(@(x)find(all(~isnan(x),2),1,'last'),M)); M = cellfun(@(x)reshape(x(1:n,:)',1,[]),M,'un',0)...

How to concentrate matrices of different row length (same column length) into one matrix by unfolding each of the matrices to the smallest row length conatining numbers not nan

M = struct2cell(H); n = min(cellfun(@(x)find(all(~isnan(x),2),1,'last'),M)); M = cellfun(@(x)reshape(x(1:n,:)',1,[]),M,'un',0)...

ongeveer 6 uur ago | 0

Answered

How to crop matrices at the maximal non-NaN values and then center the data

M = struct2cell(H); n = min(cellfun(@(x)find(all(~isnan(x),2),1,'last'),M)); for jj = 1:numel(H) H(jj).matrix = H(jj).mat...

How to crop matrices at the maximal non-NaN values and then center the data

M = struct2cell(H); n = min(cellfun(@(x)find(all(~isnan(x),2),1,'last'),M)); for jj = 1:numel(H) H(jj).matrix = H(jj).mat...

ongeveer 7 uur ago | 0

Answered

How can I extract the time column of a timetable

variant a = rand(20,6); date1 = datetime(2019,4,19) + hours(cumsum(70*rand(20,1))); TT = array2timetable(a,'RowTimes',date1...

How can I extract the time column of a timetable

variant a = rand(20,6); date1 = datetime(2019,4,19) + hours(cumsum(70*rand(20,1))); TT = array2timetable(a,'RowTimes',date1...

ongeveer 8 uur ago | 1

| accepted

Answered

combining two text file with 100 equal number of header and body text

z = dir('file*_.txt'); zn = {z.name}; n = numel(zn); c = cell(n,1); for jj = 1:numel(zn) f1 = fopen(zn{jj}); k = t...

combining two text file with 100 equal number of header and body text

z = dir('file*_.txt'); zn = {z.name}; n = numel(zn); c = cell(n,1); for jj = 1:numel(zn) f1 = fopen(zn{jj}); k = t...

1 dag ago | 0

Answered

How to assign NaN for empty cells in an array?

Finalanswer = ismember(T.Icnum,moga);

How to assign NaN for empty cells in an array?

Finalanswer = ismember(T.Icnum,moga);

1 dag ago | 0

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);

1 dag 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...

2 dagen 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(...

2 dagen 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');

2 dagen 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...

2 dagen 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(:)];

4 dagen 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)]));

4 dagen 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);

9 dagen 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 = ...

11 dagen 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][+-]...

17 dagen 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...

18 dagen 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 =...

19 dagen 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 =...

19 dagen 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 >>

20 dagen 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) =...

20 dagen 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) ...

20 dagen 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...

20 dagen 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...

20 dagen 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);

20 dagen 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...

22 dagen 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...

22 dagen 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...

22 dagen 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 ...

22 dagen 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

22 dagen 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);

22 dagen ago | 0