Bode and Nyquist plots of FRF as function of operational frequency
9 ビュー (過去 30 日間)
古いコメントを表示
I have a function for which I need to create a Bode plot and Nyquist Plot. The function describes a rotor, and is as follows. I'v built it up in parts - Hxx is a function of w (omega). k=spring stiffness, c=damping coefficient, l=length of shaft, I=moment of inertia, J=Diametral Inertia, W=rotational speed(rad/s), w=an array of frequencies between w=0:100:30000
n1=k*(l^2);
n2=w.*(i*c*(l^2));
n3=w.^2.*I;
d1=(k^2)*(l^2);
d2=w.*(2*i*c*k*(l^2));
d3=(w.^2).*((c^2*l^2)+(2*I*k)+(W*J/l)^2);
d4=(w.^3).*(2*i*c*I);
d5=(w.^4).*((I/l)^2);
Hxx=(n1+n2-n3)./(d1+d2-d3-d4+d5);
I can happily perform the following plots 1. plot(w, Hxx);
and
realHxx=real(Hxx);
imagHxx=imag(Hxx);
% Calculate the magnitude
mag=sqrt(realHxx.^2+imagHxx.^2);
plot(w, mag);
but I am now stuck as to how to produce a Bode and Nyquist plot. I suspect it is something with how to convert the function into an LTI model using frd, but I'm simply out of my depth with the documentation and cannot see how to proceed. Can anyone help please.
Don Howard
0 件のコメント
採用された回答
Arkadiy Turevskiy
2012 年 4 月 19 日
You can simply create an frd object:
sys=frd(Hxx,w);
bode(sys,w);
nyquist(sys,w);
Another option is instead of manually calculating the frequency response like you do, simply create a transfer function describing your system.
s=tf('s'); %laplace transform variable
Now modify your code to replace w with s. Also get rid of dot operations, you do not need them anymore:
n1=k*(l^2);
n2=s*(c*(l^2));
n3=(s^2)*I;
d1=(k^2)*(l^2);
d2=s*(2*c*k*(l^2));
d3=(s^2)*((c^2*l^2)+(2*I*k)+(W*J/l)^2);
d4=(s^3)*(2*c*I);
d5=(s^4)*((I/l)^2);
Hxx=(n1+n2+n3)./(d1+d2+d3+d4+d5);
I am not sure if W in d3 is the same as w. If it is, replace with s as well.
Now Hxx is a transfer function object.
Bode plot:
bode(Hxx,w);
Nyquist plot:
nyquist(Hxx,w);
HTH. Arkadiy
0 件のコメント
その他の回答 (2 件)
uopdon
2012 年 4 月 20 日
1 件のコメント
Arkadiy Turevskiy
2012 年 4 月 20 日
Ok, let me try to explain. In continuous-time domain, transfer functions are defined as functions of Laplace transform variable, s.
You start by writing your transfer function as a function of s. Your transfer function has a numerator of 2nd order and denominator of the 4th order.
So, sys=(a2*s^2+a1*s+a0)/(b4*s^4+b3*s^3+b2*s^2+b1*s+b0).
Important: in this expression, all the coefficients are the real numbers.
Now you want to calculate the magnitude at different frequencies. You do that by substituting s=i*w, where i=sqrt(-1).
Then you write your transfer function as expression of w, not s.
It becomes:
sys=(-a2*w^2+a1*i*w+a0)/(b4*s^4-b3*i*w^3-b2*w^2+b1*i*w+b0).
The problem in your code (and in my original answer, which I corrected now), is that you are trying to define a function of s using coefficients from the expression for w, and that is why you have complex values in denominator and numerator coefficients.
I hope that clarifies it.
So, to make the code correct you do this:
%% test 1 ~ Calculate Numerator and Denominator coefficients to make a
% transfer function
n0=k*(l^2); %w^0
n1=(c*(l^2)); %w^1
n2=I; %w^2
n3=0;
n4=0;
d0=(k^2)*(l^2); %w0
d1=(2*c*k*(l^2)); %w1
d2=((c^2*l^2)+(2*I*k)+(W*J/l)^2); %w2
d3=(2*c*I); %w3
d4=((I/l)^2); %w4
num=[n2 n1 n0];
den=[d4 d3 d2 d1 d0];
% plot
figure();
Hs=tf(num,den);
bode(Hs,w);
title('Bode 1 - TF1');
figure();
title('Nyquist 1 - TF1');
nyquist(Hs, w);
%% Test 2 - another method to make a transfer function
s=tf('s'); %laplace transform variable
n1=k*(l^2);
n2=s*(c*(l^2));
n3=s^2*I;
d1=(k^2)*(l^2);
d2=s*(2*c*k*(l^2));
d3=(s^2)*((c^2*l^2)+(2*I*k)+(W*J/l)^2);
d4=(s^3)*(2*c*I);
d5=(s^4)*((I/l)^2);
Hxx=(n1+n2+n3)/(d1+d2+d3+d4+d5);
figure();
bode(Hxx,w);
title('Bode 2 - TF2');
figure();
nyquist(Hxx,w);
title('Nyquist 2 - TF2');
%% Test 4 - using the Transfer function
s=tf('s'); %laplace transform variable
n1=k*(l^2);
n2=s*(c*(l^2));
n3=s^2*I;
d1=(k^2)*(l^2);
d2=s*(2*c*k*(l^2));
d3=(s^2)*((c^2*l^2)+(2*I*k)+(W*J/l)^2);
d4=(s^3)*(2*c*I);
d5=(s^4)*((I/l)^2);
Hxx4=(n1+n2+n3)/(d1+d2+d3+d4+d5);
figure();
bode(Hxx4,w);
title('Bode 4 - TF');
figure();
nyquist(Hxx4,w);
title('Nyquist 4 - TF');
Now all 4 options give the same result.
参考
カテゴリ
Help Center および File Exchange で Classical Control Design についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!