Comparing cells without loops

1 Ansicht (letzte 30 Tage)
Nik Rocky
Nik Rocky am 29 Jun. 2020
Kommentiert: dpb am 29 Jun. 2020
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?
  1 Kommentar
dpb
dpb am 29 Jun. 2020
Look at documentation for timetable and synchronize and/or retime

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Get Started with Optimization Toolbox finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by