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

9 vues (au cours des 30 derniers jours)
J
J le 16 Juil 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:

Réponse acceptée

James Tursa
James Tursa le 17 Juil 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.

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Produits


Version

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by