How to plot values from a for loop?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Maybe my question isn't so specific, but I'll try to explain what's giving me a hard time.
I have to calculate
(C/(s*I-A))*B
where A,B and C are matrices and s is a eigenvalue of some given matrix. I have to calculate it for every eigenvalue and plot it. This is what I did
svA=eig(A);
for P=1:50
fr=(CN/(i*svA(P)*eye(n)-A))*B;
fr_org{P}=fr;
end
fr_original=fr_org{1:50};
plot(fr_original)
but I didn't get anything. Any advice?
0 comentarios
Respuestas (3)
Suresh Garimella
el 3 de Feb. de 2016
Editada: Walter Roberson
el 3 de Feb. de 2016
Try this, Hope it works
svA=eig(A);
for P=1:50 fr=(CN/(i*svA(P)*eye(n)-A))*B;
fr_org{P}=fr;
end
%fr_original=fr_org{1:50}; comment this line
fr_original=fr_org; % directly assign
%plot(fr_original) comment this line
plot(cell2mat(fr_original)) % convert class using cell2mat to plot
Star Strider
el 3 de Feb. de 2016
Editada: Star Strider
el 3 de Feb. de 2016
Actually, this is incorrect:
Y = (C/(s*I-A))*B
The correct expression is:
Y = C*((s*I-A)\B)
that you then invert to create:
y = C*expm(A*t)*B
You cannot do what you want to do in the Laplace domain, especially since s = σ + j*ω. You have to invert it to the time domain to do anything with it.
If you want to do a pole-zero plot, there are functions for that such as pzplot in the Control Systems Toolbox.
2 comentarios
Star Strider
el 3 de Feb. de 2016
Editada: Star Strider
el 3 de Feb. de 2016
My pleasure.
In a pole-zero plot, σ is the real part, and jω is the imaginary part. This becomes equivalent to the Fourier transform if you set σ=0.
Ver también
Categorías
Más información sobre Loops and Conditional Statements en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!