How to manipulate nested cell arrays using for loop?
Show older comments
Hi, I have a cell array of size 1x316 with each cell different sizes.In each cell, there is two columns of data: first is speed and second is time.Both are double numeric in types. Firstly, i loaded that cell array in a structure 's1'.Its variable is called ''all_cords''.Now, using for loop, i am trying to do some arithmatics here.i need to calculate pause time variable in a cell array of size 1x316.
I need to check in each cell, if there is 0's in first column i.e speed field,if there is single 0, then pause time will be its time value and if there are multiple 0's then pause time will be tn-t0.
Thanks in advance!
Here is my codes:-
s1 = load('cell_speed_data.mat');
tpause = cell(1,length(s1.all_cords));
pause_times = cell(1,length(s1.all_cords));
for i = 1:length(s1.all_cords)
if find(s1.all_cords{i}(:,1)==0)
tpause{i} = deal(s1.all_cords{i}(:,1));
pause_times{i} = max(tpause{i}(:,1))-min(tpause{i}(:,1));
end
continue;
end;
2 Comments
Chad Greene
on 12 Mar 2016
This question is unclear. Can you provide some sample data and describe exactly what you are trying to do?
Guillaume
on 16 Mar 2016
From a dimensional analysis point of view, there is some inconsistency in the result that you want.
If there is only one time where the speed is zero, you want as an output the time at which it occurs. Hence your output is a time.
If there is more than one time where the speed is zero, you want the difference between the first and last time, so your output is a duration.
Even if both have the same unit (time), they don't represent the same thing, so how is that output going to be useful?
Accepted Answer
More Answers (0)
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!