Alternative for a for loop. How would I write this code without using a for loop to save some computation time?
显示 更早的评论
% % % Lamd is a [4096 X 46080] matrix
for x=1:64
Image=volume(:,:,x);
Img=Lamd'*Image(:);
end
5 个评论
madhan ravi
2019-3-6
编辑:madhan ravi
2019-3-6
size(volume) ?
KSSV
2019-3-6
How about Image?
madhan ravi
2019-3-6
It’s pretty clear that Image is of size 4096X1 because matrix multiplication is carried out
Viktor
2019-3-6
KSSV
2019-3-6
@madhan ravi...yes it is pretty clear ....after making it image(:). I mean to ask dimensions of image before converting it into a column.
回答(1 个)
KSSV
2019-3-6
0 个投票
Read about MTLAB element by element opeartions...I guess .* should work in your case. Also have a look on arrayfun
1 个评论
madhan ravi
2019-3-6
? arrayfun() has internal loops and is slower than an explicit loop
类别
在 帮助中心 和 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!