フィルターのクリア

Matrix loop multiplication warning

1 回表示 (過去 30 日間)
Joao
Joao 2014 年 10 月 13 日
コメント済み: Star Strider 2014 年 10 月 13 日
Hello,
I have this code:
n=1;
Eout=zeros(4096,2);
while n<=4096
E=[Eopt(n); 0]; coupler=[sqrt(0.9) 1i*sqrt(0.1);1i*sqrt(0.1) sqrt(0.9)];
Eout(n)=coupler*E;
n=n+1;
end
I would like to have the various n results from Eout (a 2x1 matrix) in 4096x2 matrix. However, when i run this code this warning appears:
??? In an assignment A(I) = B, the number of elements in B and I must be the same.
Error in ==> Sim42 at 62
What should i do?
Thanks

採用された回答

Adam
Adam 2014 年 10 月 13 日
編集済み: Adam 2014 年 10 月 13 日
Try:
Eout(n,:)=coupler*E;
though I can't tell if that is the only problem with the code you posted.
Which line is actually giving the error? Is it that line or the one above which also may be suspect depending what Eopt is.
  1 件のコメント
Joao
Joao 2014 年 10 月 13 日
Thanks!

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

その他の回答 (1 件)

Star Strider
Star Strider 2014 年 10 月 13 日
You should add an extra dimension to the ‘Eout’ assignment:
Eopt = randi(100, 4096, 1); % Create Data
n=1;
Eout=zeros(4096,2);
while n<=4096
E=[Eopt(n); 0];
coupler=[sqrt(0.9) 1i*sqrt(0.1);1i*sqrt(0.1) sqrt(0.9)];
Eout(n,:)=coupler*E;
n=n+1;
end
Then it works!
  2 件のコメント
Joao
Joao 2014 年 10 月 13 日
Thanks!
Star Strider
Star Strider 2014 年 10 月 13 日
My pleasure!

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

カテゴリ

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