cell array question finding minimums of intervals of time matrices

조회 수: 3 (최근 30일)
charles atlas
charles atlas 2014년 7월 23일
댓글: charles atlas 2014년 7월 24일
I have a cell array that is a 1:100 cell (cellarray1). each one of the contents of that cell is ALSO a cell. The contents of each of those cells is time data that is either a 1X20 double, 1:30 double, a 1X200 double or anywhere in between.
I want to loop through the whole cell array, take every matrix of time data in the cell array, then we will say that m= the length of any random array of time data in the cell array. For each of the arrays of time data, I want to take the (2:m)-(1:m-1). Then I will have the deltas between the time points for every cell array in the intire cell array.
Then I want to take the minimum number of each cell array and store that in an array.
(I can then use datestr(timearray1),'HH:MM:SS.FFF') to get all the minimum time intervals for every array in cellarray1.
  댓글 수: 3
charles atlas
charles atlas 2014년 7월 23일
for k=1:length(cellarray1)
dt(k)={cellarray1{1,k}(2:length(cellarray1{1,k}))...
-cellarray1{1,k}(1:length(cellarray1{1,k})-1)};
end
If I do that, I get error: In an assignment A(:) = B, the number of elements in A and B must be the same.
But the output to that for loop woould point me in the right direction because all I would have to do is make a simple loop to go through all of the elements in dt and do the min of them, output that into timearray1, then do the datestr of that.
charles atlas
charles atlas 2014년 7월 23일
Also if I do this instead (change dt(k) to just dt), it gives me a 1X2 cell array of the first two subtracted cell arrays from cellarray1.
for k=1:length(cellarray1)
dt={cellarray1{1,k}(2:length(cellarray1{1,k}))...
-cellarray1{1,k}(1:length(cellarray1{1,k})-1)};
end

댓글을 달려면 로그인하십시오.

채택된 답변

dpb
dpb 2014년 7월 23일
편집: dpb 2014년 7월 23일
dt=cellfun(@diff,array,'uniformoutput',false);
mindt=cellfun(@min,dt);
doc cellfun % for the gory details...

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by