How to store complex data into an array using a For loop?
6 ビュー (過去 30 日間)
古いコメントを表示
I am trying to store data that contains complex numbers into an array. I am having issues on how to setup the loop and extract the data. The error I am getting says "Subscript indices must either be real positive integers or logicals" which is in code line 12.
i=1;
for k=10e-10:0.01:10 %discrete reduced frequency range
Ck = (besselh(1,2,k))./(besselh(1,2,k)+1i*besselh(0,2,k)); %Bessel function
%Matrices
A=[0.8132 -0.1008; -0.0725 2.0518];
B=Ck*[7.623 57.15; -8.233 -57.157];
C=Ck*[1865 1473.14; -1119 11907.48];
%frd function
Hresp=frd(Abar,k);
H11(i)=Hresp;
i=i+1;
end
I would like my output data to look like this:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/191992/image.png)
0 件のコメント
採用された回答
James Tursa
2018 年 7 月 17 日
Type this at the MATLAB prompt:
dbstop if error
Then run your code. When the error occurs, the code will pause with all current variables intact. Examine them to figure out why the index you are using is not what you expected it to be.
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!