Comparison between continuous and discrete transfer function s, z, to w

I was trying to do a Bode/Nyquist Plot of a transfer function in both continuous and discrete mode
My system has a sampling frequency of 15 kHz. I am trying to compare Bode Plots of continuous and discrete functions. I transformed my function from s to z and then to w.
My function is a resonant controller with damping.
Gv6(nn)=tf([0 kp],[0 1])+tf([k1*nn 0],[1,2*zeta*w0,(w0)^2])+tf([k5*nn 0],[1,2*zeta*5*w0,(5*w0)^2])+tf([k7*nn 0],[1,2*zeta*7*w0,(7*w0)^2])+tf([k11*nn 0],[1,2*zeta*11*w0,(11*w0)^2])+tf([k13*nn 0],[1,2*zeta*13*w0,(13*w0)^2])+tf([k17*nn 0],[1,2*zeta*17*w0,(17*w0)^2])+tf([k19*nn 0],[1,2*zeta*19*w0,(19*w0)^2])+tf([k23*nn 0],[1,2*zeta*23*w0,(23*w0)^2]);
nn=1 in this case zeta=0.03, w0=2*pi*50, kp=1, all other kn=250*2*zeta*n*w0, n harmonic number
I am using the following functions:
sys=Gv6(1);
opt = c2dOptions('Method','tustin','PrewarpFrequency',2*pi*f);
sysd = c2d(sys,Tsamp,opt);
[num,den] = tfdata(sysd);
syms z
t_sym = poly2sym(cell2mat(num),z)/poly2sym(cell2mat(den),z);
syms z w
Tsamp=1/15000;
G=t_sym;
GN=subs(G,z,(2+Tsamp*w)/(2-Tsamp*w));
[n,d]=numden(GN);
eq1 = n;
eq2 = d;
s = tf('s');
eq1_s = strrep(char(eq1),'w','s');
eq2_s = strrep(char(eq2),'w','s');
G = eval(eq1_s) / eval(eq2_s);
bode(Gv6(1),sysd); hold on;grid on;
bode(G); hold on;grid on;
So far the continues and discrete plots does not look similar in the lower frequencies, but look OK at high frequencies, What is wrong with my code?

Answers (1)

Hi,
The problem in lower frequency arose because when in your manual “inverse” step you wrote:
z = (2 + Ts*w)/(2 - Ts*w); % <-- K is missing here
That assumed K=1. Dropping K changes the dc (low-frequency) gain, which is why the two Bode plots only matched at higher frequencies (they cross exactly at the pre-warp frequency where the scale error is zero).
To fix this you can let MATLAB undo the mapping for you:
sysc_from_d = d2c(sysd,'tustin',wp); % use SAME wp
bode(sys, sysc_from_d), grid on
Now 'd2c' knows about the K factor, so the curves sit on top of each other everywhere.
Here is more information on 'd2c' :
Hope this helps!

Categories

Find more on MATLAB in Help Center and File Exchange

Products

Release

R2018b

Asked:

on 14 Apr 2019

Answered:

on 17 Jun 2025

Community Treasure Hunt

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

Start Hunting!