Hello,
I'm searching in multiple cell-array for some data:
for traj_cnt = 1:size(Traj_interpl,2)
for t_row_cnt = 1:size(Traj_interpl{traj_cnt},1)
if t_interpl(t_ref_cnt) == Traj_interpl{traj_cnt}(t_row_cnt,1)
motorspeed_detected(traj_cnt) = Traj_interpl{traj_cnt}(t_row_cnt,2);
break;
else
motorspeed_detected(traj_cnt) = 0;
end
end
end
Sometimes there are too much cells and rows, so is takes long long time and matlab in else state. What can I do to optimize a code?
traj_cnt is a variable of number of cells
Traj_interpl is a big cell array
t_row_cnt is a variable rows in one cell
t_interpl(t_ref_cnt) is a counting time variable (+10 ms) (initialisation outside)
Traj_interpl{traj_cnt}(t_row_cnt,1) is a saved time in cell arrays that I'm looking vor
Traj_interpl{traj_cnt}(t_row_cnt,2) is a saved motor value in cell array tham I try to save
motorspeed_detected array with detected values
So, I'm looking for special time in first column of cell arrays and if I find this, I take a value from second coloumn and save it to motorspeed_detected array.
How can I save resources? Thank you!