How can I save for loop results to array?

I have a for loop to calculate this matrix. This have only one variable named w.
This is the for loop. The 'eVcounter' is equal to above w.
How can I save data for every loop?

 採用された回答

Image Analyst
Image Analyst 2022 年 12 月 22 日

2 投票

You need to index the arrays
w = 1.5 : 0.5 : 4.5;
for k = 1 : length(w)
eVcounter = w;
Amp = complicated Expression
% etc.
Cb(k) = invAmp(1,:) * b;
end

4 件のコメント

빈찬 주
빈찬 주 2022 年 12 月 22 日
Thank you ..
But , There is a problem..
The 'Amp' is 3 by 9 matrix,, so,, the inverse matrix cannot availabe...
Image Analyst
Image Analyst 2022 年 12 月 22 日
Put commas between the three terms on each line of Amp. Then it's a 3x3 matrix.
VBBV
VBBV 2022 年 12 月 22 日
w = 1.5 : 0.5 : 4.5;
for k = 1 : length(w)
eVcounter = w(k); % also this small change
Amp = complicated Expression
% etc.
Cb(k) = invAmp(1,:) * b;
end
Do also this small change in the above code
eVcounter = w(k);
빈찬 주
빈찬 주 2022 年 12 月 25 日
Thank you :D

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

その他の回答 (0 件)

カテゴリ

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

製品

リリース

R2022a

質問済み:

2022 年 12 月 22 日

コメント済み:

2022 年 12 月 25 日

Community Treasure Hunt

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

Start Hunting!

Translated by