Answered

How to loop this operation ?

ii = 300:-20:20; D = TarG(ii)./[100;TarG(ii(2:end) + 1)]; Tot_TarG = cumprod(D);

How to loop this operation ?

ii = 300:-20:20; D = TarG(ii)./[100;TarG(ii(2:end) + 1)]; Tot_TarG = cumprod(D);

3 days ago | 1

| accepted

Answered

Converting two matrix to a single table

T = table(reshape(M1',[],1),reshape(M2',[],1)); T.properties.VariableNames = {'M1_value','M2_value'};

Converting two matrix to a single table

T = table(reshape(M1',[],1),reshape(M2',[],1)); T.properties.VariableNames = {'M1_value','M2_value'};

3 days ago | 0

Answered

I have time series data of 1 year each day 2880 values row wise so a matrix of 365X2880. I want to do monthly average. January 31 days average one file of one month, so that I can finally get 12 files each of monthly average.

A - you're array 365 x 2880, in example per 2015 year. t = (datetime(2015,1,1):datetime(2015,12,31))'; TT = array2timetable(A,...

I have time series data of 1 year each day 2880 values row wise so a matrix of 365X2880. I want to do monthly average. January 31 days average one file of one month, so that I can finally get 12 files each of monthly average.

A - you're array 365 x 2880, in example per 2015 year. t = (datetime(2015,1,1):datetime(2015,12,31))'; TT = array2timetable(A,...

3 days ago | 1

| accepted

Answered

getting the max and its positions from a 4D array

Maybe this: [m,n,k,f] = size(totalDistance);% here k = 1 [~,ij] = max(totalDistance,[],4); [I,J,K] = ndgrid(1:m,1:n,1:3); F ...

getting the max and its positions from a 4D array

Maybe this: [m,n,k,f] = size(totalDistance);% here k = 1 [~,ij] = max(totalDistance,[],4); [I,J,K] = ndgrid(1:m,1:n,1:3); F ...

3 days ago | 0

Answered

sum of timetables for each months

Buses = [5;8]; cars = [10;18]; Time = datetime(2019,[8;9],1); buses = timetable(Time,Buses); cars = timetable(Time,cars); ...

sum of timetables for each months

Buses = [5;8]; cars = [10;18]; Time = datetime(2019,[8;9],1); buses = timetable(Time,Buses); cars = timetable(Time,cars); ...

5 days ago | 1

| accepted

Answered

sub2ind Get values of 3D matrix using an index array?

[m,n,k] = size(M); [q,w] = ndgrid(1:m,1:n); out = M(sub2ind([m,n,k],q,w,A));

sub2ind Get values of 3D matrix using an index array?

[m,n,k] = size(M); [q,w] = ndgrid(1:m,1:n); out = M(sub2ind([m,n,k],q,w,A));

5 days ago | 2

| accepted

Answered

List(Vecor) Generation

m=3; n=4; T = 1:m*n; out = ceil(T/m) + mod(T-1,m); or out = floor(T/n) + mod(T-1,m) + 1; or out = repmat(1:m,1,n) + rep...

List(Vecor) Generation

m=3; n=4; T = 1:m*n; out = ceil(T/m) + mod(T-1,m); or out = floor(T/n) + mod(T-1,m) + 1; or out = repmat(1:m,1,n) + rep...

7 days ago | 0

Answered

HOW Calculate the distance of points form one center in 2-D space and display output in a distance matrix?

X = rand(5,1) Y = rand(5,1) D = squareform(pdist([X,Y])) or XY = [X, Y]; D = sqrt(squeeze(sum((XY - permute(XY,[3,2,1])).^2...

HOW Calculate the distance of points form one center in 2-D space and display output in a distance matrix?

X = rand(5,1) Y = rand(5,1) D = squareform(pdist([X,Y])) or XY = [X, Y]; D = sqrt(squeeze(sum((XY - permute(XY,[3,2,1])).^2...

8 days ago | 1

Answered

How can I convert this table to a cell array as shown in the screenshot?

tout = varfun(@(x){x(:)'},T,'GroupingVariables','id'); C = tout{:,3:end}; measure = C(:,1); t = C(:,2);

How can I convert this table to a cell array as shown in the screenshot?

tout = varfun(@(x){x(:)'},T,'GroupingVariables','id'); C = tout{:,3:end}; measure = C(:,1); t = C(:,2);

9 days ago | 2

| accepted

Answered

for loop values of certain output range

x = 3; c = -2:1:2; q = -2:1:2; g = c*x + q.*(c+x); lo = g >= 5 & g <= 10; out = table(c(lo),q(lo),g(lo),'Variablenames',{'c...

for loop values of certain output range

x = 3; c = -2:1:2; q = -2:1:2; g = c*x + q.*(c+x); lo = g >= 5 & g <= 10; out = table(c(lo),q(lo),g(lo),'Variablenames',{'c...

10 days ago | 0

Answered

Reading content of a file using readtable return NaT for Time

T = readtable('eventlog.txt','format',... '%d %{yyyy-MM-dd HH:mm:SS}D %s %s %s','delimiter','|',... ...

Reading content of a file using readtable return NaT for Time

T = readtable('eventlog.txt','format',... '%d %{yyyy-MM-dd HH:mm:SS}D %s %s %s','delimiter','|',... ...

10 days ago | 0

Answered

how to count daily events from a time series data

out = varfun(@(x)x,T,'GroupingVariables',{'Year','month','day'},... 'Inpu...

how to count daily events from a time series data

out = varfun(@(x)x,T,'GroupingVariables',{'Year','month','day'},... 'Inpu...

11 days ago | 0

Answered

Creating a matrix having repeating elements

A = kron(eye(5),[1;1])+kron(diag(-ones(4,1),1),[1;1]); out = A(1:5,:); or n = 1:5; A = repmat([1,-1,0,0,0],5,1); out = A(mo...

Creating a matrix having repeating elements

A = kron(eye(5),[1;1])+kron(diag(-ones(4,1),1),[1;1]); out = A(1:5,:); or n = 1:5; A = repmat([1,-1,0,0,0],5,1); out = A(mo...

11 days ago | 1

| accepted

Answered

How to cite the row of the matrix by vectorization?

For large matrices, the cycle may be faster. a = repmat(1:6,3,1)'; index = [1:3;2:4]; si = size(index); result = permute...

How to cite the row of the matrix by vectorization?

For large matrices, the cycle may be faster. a = repmat(1:6,3,1)'; index = [1:3;2:4]; si = size(index); result = permute...

12 days ago | 0

| accepted

Answered

General Binomial Matrix Manipulation

Aend = reshape(Abegin.*permute(Abegin,[1,3,2]),size(Abegin,1),[]);

General Binomial Matrix Manipulation

Aend = reshape(Abegin.*permute(Abegin,[1,3,2]),size(Abegin,1),[]);

12 days ago | 1

Answered

A cycle for creating and working with zones

n = numel(Data); ii = ceil((1:n)'/100); TF = accumarray(ii,Data(:),[],@(x){isoutlier(x)});

A cycle for creating and working with zones

n = numel(Data); ii = ceil((1:n)'/100); TF = accumarray(ii,Data(:),[],@(x){isoutlier(x)});

12 days ago | 0

| accepted

Answered

array manipulation in loop through a sequence

E = ones(4); n = size(E,1); for ii = 1:n E(ii,n-ii+1:n) = E(ii - 1 + (ii == 1),n-ii+1:n) + 1 end

array manipulation in loop through a sequence

E = ones(4); n = size(E,1); for ii = 1:n E(ii,n-ii+1:n) = E(ii - 1 + (ii == 1),n-ii+1:n) + 1 end

13 days ago | 1

| accepted

Answered

Matrix problem for same values of column

[m,n] = size(A); B = [(1:m)',A(:,2:3)]; k = B(1,2:3); ii = 1; C{1} = []; while ~isempty(B) i0 = ismember(B(:,2:3),k); ...

Matrix problem for same values of column

[m,n] = size(A); B = [(1:m)',A(:,2:3)]; k = B(1,2:3); ii = 1; C{1} = []; while ~isempty(B) i0 = ismember(B(:,2:3),k); ...

13 days ago | 0

Answered

function to fill in zeros

data=[100 95 0 90 0 85 0 0 70 65 ]'; data(data == 0) = nan; new_data = fillmissing(data,'linear'); or ii = (1:numel(data))...

function to fill in zeros

data=[100 95 0 90 0 85 0 0 70 65 ]'; data(data == 0) = nan; new_data = fillmissing(data,'linear'); or ii = (1:numel(data))...

13 days ago | 2

| accepted

Answered

Averaging the previous 5 values of every 30 values in a matrix

m = size(numData,1); lo = mod((0:m-1)',30) + 1 >= 26; ii = ceil((1:m)'/10); HRmean5 = accumarray(ii(lo),numData(lo,3),[],@mea...

Averaging the previous 5 values of every 30 values in a matrix

m = size(numData,1); lo = mod((0:m-1)',30) + 1 >= 26; ii = ceil((1:m)'/10); HRmean5 = accumarray(ii(lo),numData(lo,3),[],@mea...

13 days ago | 0

Answered

Generate a N length vector from a M length list (permutation)

out = fullfact(3*ones(1,5));

Generate a N length vector from a M length list (permutation)

out = fullfact(3*ones(1,5));

13 days ago | 0

Answered

Find rows in matrix based on columns value

My case for mat: mat = [1 11 3 10 5 6 10 10 9 10 11 12]; mat2 = sort(mat,2); [m,n...

Find rows in matrix based on columns value

My case for mat: mat = [1 11 3 10 5 6 10 10 9 10 11 12]; mat2 = sort(mat,2); [m,n...

13 days ago | 2

Answered

Sum if multiple conditions satisfied across vectors

MKT = [1 ; 1 ; 1 ; 2 ; 2 ; 2]; GROUP = [1 ; 1 ; 2 ; 1 ; 2 ; 2]; SHARE = [0.2 ; 0.3 ; 0.5 ; 0.6 ; 0.1 ; 0.3]; T = table(MK...

Sum if multiple conditions satisfied across vectors

MKT = [1 ; 1 ; 1 ; 2 ; 2 ; 2]; GROUP = [1 ; 1 ; 2 ; 1 ; 2 ; 2]; SHARE = [0.2 ; 0.3 ; 0.5 ; 0.6 ; 0.1 ; 0.3]; T = table(MK...

13 days ago | 0

| accepted

Answered

Replace row of matrix with vector by logical indexing

a = 101:120; lo = a(:) > 112; b(lo,:) = lo(lo>0).*[55,56,57,58,59];

Replace row of matrix with vector by logical indexing

a = 101:120; lo = a(:) > 112; b(lo,:) = lo(lo>0).*[55,56,57,58,59];

13 days ago | 0

Answered

How to find unique combinations between two columns in a cell array

test = {'sensor1', 'sensor1', 'sensor2', 'sensor2', 'sensor3', 'sensor3'; '99' '99' '98' '97' '98' '97'}' T = cell2table(t...

How to find unique combinations between two columns in a cell array

test = {'sensor1', 'sensor1', 'sensor2', 'sensor2', 'sensor3', 'sensor3'; '99' '99' '98' '97' '98' '97'}' T = cell2table(t...

14 days ago | 0

| accepted

Answered

how to Expanand any matrix

out = cell2mat(arrayfun(@(x,y)diag(ones(5-x,1),x)*y ,abs(a),a>=0,'un',0)); or z = cell(size(a)); k = zeros(5); for ii = 1:nu...

how to Expanand any matrix

out = cell2mat(arrayfun(@(x,y)diag(ones(5-x,1),x)*y ,abs(a),a>=0,'un',0)); or z = cell(size(a)); k = zeros(5); for ii = 1:nu...

14 days ago | 0

Answered

recode the missing values equal to the preceding recorded value

lo = anuual_CO2(:,2) ~= -999; x = anuual_CO2(lo,2); anuual_CO2(:,2) = x(cumsum(lo));

recode the missing values equal to the preceding recorded value

lo = anuual_CO2(:,2) ~= -999; x = anuual_CO2(lo,2); anuual_CO2(:,2) = x(cumsum(lo));

14 days ago | 0

Answered

add new rows to a Matrix

A = rand(11,6); out = addedNansRows(A,3,4) Here addedNansRows: function out = addedNansRows(A,m,n) % A - array % m -...

add new rows to a Matrix

A = rand(11,6); out = addedNansRows(A,3,4) Here addedNansRows: function out = addedNansRows(A,m,n) % A - array % m -...

15 days ago | 2

| accepted

Answered

How to call a specific element of a table

load data.mat lo = ismembertol(T{:,{'time','perhexagon'}},[2,2.1667],'ByRows',true,... ...

How to call a specific element of a table

load data.mat lo = ismembertol(T{:,{'time','perhexagon'}},[2,2.1667],'ByRows',true,... ...

17 days ago | 0