Answered

How to calculate averaged values from 5-min interval values

For old version of the MATLAB (MATLAB <= R2016a): T = readtable('Experiment.xlsx','ReadVariableNames',false); z = regexp(T.Va...

How to calculate averaged values from 5-min interval values

For old version of the MATLAB (MATLAB <= R2016a): T = readtable('Experiment.xlsx','ReadVariableNames',false); z = regexp(T.Va...

2 days ago | 0

Answered

Nearest value from an array.

M=[1,2,3,4,5,6,7,8,910] N=[0.5,1.3,2.4] [~,ii] = min(abs(M(:) - N(:)')); out = M(unique(ii));

Nearest value from an array.

M=[1,2,3,4,5,6,7,8,910] N=[0.5,1.3,2.4] [~,ii] = min(abs(M(:) - N(:)')); out = M(unique(ii));

2 days ago | 0

| accepted

Answered

Selecting cross values from two arrays

s = [0,1000,2000]; d = [0,1000,2000]; J = [0,5000,8000]; ii = fullfact([3,3,3]); out = [s(ii(:,1))',d(ii(:,2))',J(ii(:,...

Selecting cross values from two arrays

s = [0,1000,2000]; d = [0,1000,2000]; J = [0,5000,8000]; ii = fullfact([3,3,3]); out = [s(ii(:,1))',d(ii(:,2))',J(ii(:,...

5 days ago | 0

Answered

Sample data from time-dependent array

data = [ 228.0000 23.7800 236.0000 23.8767 244.0000 23.9400 256.0000 24.1400 268.0000 23.8200 276.0000 2...

Sample data from time-dependent array

data = [ 228.0000 23.7800 236.0000 23.8767 244.0000 23.9400 256.0000 24.1400 268.0000 23.8200 276.0000 2...

6 days ago | 0

| accepted

Answered

How to extract first non-zero element in each column and put into a new array

out = in(cumsum(cumsum(in~=0)) == 1)'

How to extract first non-zero element in each column and put into a new array

out = in(cumsum(cumsum(in~=0)) == 1)'

6 days ago | 1

Answered

Finding consecutive data with non zero in array

x = ~xx(:); nn = numel(x); n = diff([find(diff([1;x(:)])~=0);nn+1]); y = mod(2 - x(1) +(0:numel(n)-1)',2); lo = repelem(~all...

Finding consecutive data with non zero in array

x = ~xx(:); nn = numel(x); n = diff([find(diff([1;x(:)])~=0);nn+1]); y = mod(2 - x(1) +(0:numel(n)-1)',2); lo = repelem(~all...

6 days ago | 0

Answered

Finding index location in volume?

x = 2000:0.5:2004; y = 45000:0.3:45009; z = 10:0.2:12; x0 = 2002.13; y0 = 45006.811; z0 = 11.36; C = nan(9,31,11); ...

Finding index location in volume?

x = 2000:0.5:2004; y = 45000:0.3:45009; z = 10:0.2:12; x0 = 2002.13; y0 = 45006.811; z0 = 11.36; C = nan(9,31,11); ...

6 days ago | 1

| accepted

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

10 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'};

10 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,...

10 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 ...

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

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

12 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...

14 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...

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

16 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...

17 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','|',... ...

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

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

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

19 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),[]);

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

19 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

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

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

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

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

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

20 days ago | 2