How to store complex data into an array using a For loop?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
J
am 16 Jul. 2018
Beantwortet: James Tursa
am 17 Jul. 2018
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 Kommentare
Akzeptierte Antwort
James Tursa
am 17 Jul. 2018
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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!