Info

此问题已关闭。 请重新打开它进行编辑或回答。

Eliminating a for loop for faster computation

1 次查看(过去 30 天)
HI, FInd below part of my code .Is it possible to substitute the for loop so that it is faster and takes less computation?
time_durations=zeros(length(out),1)';
for k=1:length(out)
time_durations(k)=minutes(time_select_20000(out(k,3))-time_select_20000(out(k,2)));
end

回答(1 个)

Walter Roberson
Walter Roberson 2015-6-26
Have you tried
minutes(time_select_20000(out(:,3))-time_select_20000(out(:,2)))
with no loop?
  2 个评论
yashvin
yashvin 2015-6-26
Yes it works! Based on your experience, in this particular case, which one would you suggest?

此问题已关闭。

标签

Community Treasure Hunt

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

Start Hunting!

Translated by