Comparing cells without loops

조회 수: 1 (최근 30일)
Nik Rocky
Nik Rocky 2020년 6월 29일
댓글: dpb 2020년 6월 29일
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
dpb
dpb 2020년 6월 29일
Look at documentation for timetable and synchronize and/or retime

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by