How to store complex data into an array using a For loop?

9 次查看(过去 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:

采纳的回答

James Tursa
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 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

产品


版本

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by