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
madhan ravi 2019 年 3 月 6 日
編集済み: madhan ravi 2019 年 3 月 6 日
size(volume) ?
KSSV
KSSV 2019 年 3 月 6 日
How about Image?
It’s pretty clear that Image is of size 4096X1 because matrix multiplication is carried out
Viktor
Viktor 2019 年 3 月 6 日
Volume is [64 x 64 x 64] matrix
KSSV
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
KSSV 2019 年 3 月 6 日
Read about MTLAB element by element opeartions...I guess .* should work in your case. Also have a look on arrayfun

1 件のコメント

? arrayfun() has internal loops and is slower than an explicit loop

サインインしてコメントする。

カテゴリ

ヘルプ センター および File Exchange で Loops and Conditional Statements についてさらに検索

質問済み:

2019 年 3 月 6 日

コメント済み:

2019 年 3 月 6 日

Community Treasure Hunt

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

Start Hunting!

Translated by