Using for loops to calculate a function that outputs a matrix and I want to store it into a matrix?

3 ビュー (過去 30 日間)
Hello,
I have an exponential function that needs to be solved 41 times and stored in 41 different matrices. Here's what I have:
for i = 0:40;
for a = 1:41
E = exp((-1i).*2.*i.*x);
matrix{1,a} = E;
end
end
Can someone help? Thanks!

採用された回答

Matthew Eicholtz
Matthew Eicholtz 2016 年 3 月 22 日
One way to simplify this:
for ii=0:40
m{ii+1} = exp(-i.*2.*ii.*x);
end
NOTE: I assume the '-1i' in your exponential is meant to be the complex number '0-1i'. If so, you should change the for-loop iterator from i to ii or something else.
  1 件のコメント
Sean Raffetto
Sean Raffetto 2016 年 3 月 22 日
Great! Thank you! I tend to make it really hard on myself with naming conventions.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by