Borrar filtros
Borrar filtros

I am trying to find the dominant poles without using a for loop...

2 visualizaciones (últimos 30 días)
Abraham Sikes
Abraham Sikes el 24 de Abr. de 2020
Respondida: Raunak Gupta el 29 de Abr. de 2020
This is what I have so far, and it is driven by the fact my professor says he does not want to see overly similar code as the others in my class... But I dont know how to find the dominant poles from this without a for loop like so many of my classmates will have... Any Ideas?
num=[3 3];
den=[conv([1 0],[conv([1 4],[1 7])])]
Gs1=tf(num,den)
hold on
rlocus(Gs1)
GS1=zpk(Gs1)
%%
R=[-0.1:-0.3:-5.8];
I=i*[0.01:0.01:0.5];
[Re Im]=meshgrid(R,I);
p=Re+Im;
p_s=sort(p);
%% angle from double pole at zero
Theta=180-angle(p);
Ts=sort(Theta);
%% distances from -7 to possible poles on Re axis
P4=-7;
P4d=P4-real(p_s(1,1:20));
%% distances from -4 to possible poles on Re axis
P3=-4;
P3dA=P3-real(p_s(1,1:13));
P3dO=real(p_s(1,15:20))-P3;
P3d=[P3dA,0,P3dO];
%% distance from zero poles to prime pole possible
P1_2=real(p_s);
%% Angles from "dP" to -4
ThP3A=atan2(imag(p_s(1:50,1:13)),P3dA);
ThP3O=180-atan2(imag(p_s(1:50,15:20)),P3dO);
ThP390=90*ones(1,50)';
ThP3=[ThP3A,ThP390,ThP3O];
%% Angles from "dP" to -7
ThP4=180-atan2(imag(p),P4d);
%% Finding Angle Deficiencies
ANGDef=180-ThP4-ThP3-2*Ts;
AngN=ANGDef/2;
xprime=1./tan(180-AngN);
x=[0:-.3:-5.8];
a_val1=x+xprime

Respuestas (1)

Raunak Gupta
Raunak Gupta el 29 de Abr. de 2020
Hi,
I don’t see any for loop in the code that is provided with the question, however if there is a for loop you can always write the code using array indexing so that you will be dealing vector in a matrix rather than going in a for loop. Array indexed code is also faster than the for loop one. You may find following article and documentation useful.

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by