Look at documentation for timetable and synchronize and/or retime
Comparing cells without loops
1 次查看(过去 30 天)
显示 更早的评论
Hello,
I have one 1x5 cell-array G with 3000 x 1 doubles and one R 1x20 cell array with var x 2. The first column marked bold is time. Both of cell array has a same time base t. G has all t-values from 1 to 3000. R has different pieces and are not always here.
Cell looks:
G = (I skip {})
1 12 44 78 45
2 14 58 45 22
3 45 78 79 13
4 2 45 45 45
5 14 56 45 78
.....................
3000 45 78 45 12
%%%%%%%%%%%
R{1} =
2 47
3 78
%%%%%%%%%%%
R{2} =
3 45
4 47
5 66
%%%%%%%%%%%
R{n} =
12 45
13 45
14 40
%%%%%%%%%%%
Now I want to compare data between cells. I put it in double loop for G and double loop R. indexes are looking for right time point and set a values to array G_save or R_Save.
Pseudo code looks:
%%%%%%%%%%%%%%%%%%%%%%%%%%% G
for time_cnt from zero to 3000 %%%% from 1 to 3000
for cell number %every cell
for any row
if time_cnt equal row value in first column
G_save(cell_number_cnt) = save four values
else
G_save(cell_number_cnt) = save zero
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%% R
for cell number
for any row
if time_cnt equals row value in first column
R_save(cell_numer_cnt2) = value
else
R_save(cell_numer_cnt2) = 0
end
end
...... calkulation
end
All this loops take very much time- Can you help me please to avoid a loos?
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Get Started with Optimization Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!