I wrote a loop code in matlab the problem is the answer I got is for the last element of the loop V =[0.0312 + 0.2251i 0.0312 - 0.2251i -0.4103 -0.0103 -0.6718 -0.6718 0.7873 0.1565 0.1714 + 0.1472i 0.1714 - 0.1472i -0.2127 -0.0645 -0.5006 + 0.4421i -0.5006 - 0.4421i 0.4082 0.9855 ]
j=1; [m n]=size(V); b=zeros(n,n);
while (j <= n)
if isreal(V(:,n))==0
b(:,n)=real(V(:,n))
b(:,n+1)=imag(V(:,n))
j=j+1
else
b(:,n)=V(:,n)
end
j=j+1
end

 採用された回答

Adam
Adam 2014 年 12 月 5 日
編集済み: Adam 2014 年 12 月 5 日

0 投票

You should be using
b(:,j) = V(:,j)
not n in your loop, which also should probably be a for loop, but that's a side issue - a while still works. And obviously all the other places you are using n instead of j too

1 件のコメント

Ahmed
Ahmed 2014 年 12 月 6 日
Thank You

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

その他の回答 (0 件)

カテゴリ

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

タグ

質問済み:

2014 年 12 月 5 日

コメント済み:

2014 年 12 月 6 日

Community Treasure Hunt

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

Start Hunting!

Translated by