How to store matrix data (Imaginary) from a loop

6 ビュー (過去 30 日間)
Matthew Worker
Matthew Worker 2015 年 9 月 3 日
コメント済み: Walter Roberson 2015 年 9 月 4 日
Hello, In my project I have a loop and each iteration gives me a matrix with imaginary values:
for fi = 0:10000:1100000
....
A1=[a11,a12;a21,a22]
end
Output:
A1 =
1.0e+02 *
-0.0934 + 0.0245i -9.0639 + 3.2366i
-0.0010 + 0.0002i -0.0934 + 0.0245i
I need to store all this matrixes with relation to fi value. I am going to use few similar loops and multiply output matrixes (for the same value of fi).
I try to use
A1(fi)=[a11,a12;a21,a22]
but have below error:
Subscript indices must either be real positive integers or logicals.
Can I please any ideas and tips? :)

採用された回答

Walter Roberson
Walter Roberson 2015 年 9 月 4 日
fivals = 0:10000:1100000;
numfi = length(fivals);
A1 = cell(numfi, 2);
for fiidx = 1 : numfi
fi = fivals(fiidx);
....
A1{fiidx, 1} = fi;
A1{fiidx, 2} = [a11,a12;a21,a22]};
end
Now A1 will be an N x 2 cell array in which the first column is the fi values and the second column is the A1 arrays that resulted.
  2 件のコメント
Matthew Worker
Matthew Worker 2015 年 9 月 4 日
that works perfect :)
Is it any way to store this data in Matlab memory and then multiply each A1 array * A2 array (from another loop) - for the same values of fi?
Walter Roberson
Walter Roberson 2015 年 9 月 4 日
assuming that the list of fi are the same, then
A3(:,2) = cellfun(@mtimes, A1(:,2), A2(:,2), 'Uniform', 0);
A3(:,1) = A1(:,1);
If the fi are certain to be there and to be bit-wise identical but not in the same order then different code would be used. If the fi are certain to be approximately there but not necessarily bitwise identical and not in the same order then different code yet would be used. If the fi are not certain to all be present between the two then you need to define the behaviour for the cases that do not match.

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

その他の回答 (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