matlabsimulationtransfer-function

Simulations of discrete transfer functions with different results


I have created 'same' discrete transfer function in two different modes. Then I simulated them against the same input.

Why are the results different? What is the difference between the two?

Code:

close all;clear;clc;
Ts=0.001;
t = 0:Ts:10;
%input
u=rand(length(t),1);
%1st TF
test_tf=c2d( tf([8 18 32],[1 6 14 24]),Ts );
y=lsim(test_tf,u,t);
%2nd TF
test_d_tf=tf([0.007985 -0.01595 0.007967],[1 -2.994 2.988 -0.994],Ts);
y_d=lsim(test_d_tf,u,t);
%plotting
plot(t,u,'k:',t,y,'b-',t,y_d,'r--');

And their results are:

Entire simulation interval:

entire simulation interval

and Zoomed:

zoomed


Solution

  • My guess is because the tfs aren't actually the same, they only look it because of the formatting:

    >>format long
    >>test_d_tf.Numerator{1}
    ans =
         0   0.007985000000000  -0.015950000000000   0.007967000000000
    >> test_tf.Numerator{1}
    
    ans =
         0   0.007985016651180  -0.015952055311304   0.007967070564278