Can I vectorise or make this 'find' double-loop run faster?
3 次查看(过去 30 天)
显示 更早的评论
Hi, Is there a possible way in which the formula that uses 'find' to update a matrix could do away with the double loops and make this calculation faster. Inputs:
1) Cmat - a 13x13 matrix,
2) Hist - a 1000x21 matrix of random numbers,
3) Chain - a 1000x22 matrix, such that Chain(:,1) contains numbers 1:13 and Chain(:,2:22) are zeros.
I run two loops to update the Chain matrix as follows:.
for i=2:size(Chain,2);
for k=1:size(Hist,1)
Chain(k,i) = find(Hist(k,i)< Cmat(Chain(k,i-1),:),1);
end
end
any suggestions are welcome.
Thanks for your inputs.
jayant
0 个评论
采纳的回答
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!