simulate a continuous time system in matlab

Viewed 31

I'm trying to simulate a continuous time system but i can't find a solution to this error. I tried many days and can't figure out what is the error in the code.

Please help out .

clc;
Ts=0.1;
T=0:0.1:5;
N=50;
numc=[1 0.3 4 0.6 3];
denc=[1 0.3 6 1.2 10 1.2 4];
sysc=tf(numc,denc);
ud=idinput(N,'prbs',[0 0.1],[-1 1]);
x0 = [0;0;0;0];
yd=lsim(sysc,ud,T);
1 Answers

The N elements number is wrong. The length of the vector generated in T=0:0.1:5; must be the same that uses the idinput function.

Example:

clc;
Ts=0.1;
T=(0:Ts:5)';
N=length(T);
numc=[1 0.3 4 0.6 3];
denc=[1 0.3 6 1.2 10 1.2 4];
sysc=tf(numc,denc);
ud=idinput(N,'prbs',[0 0.1],[-1 1]);
x0 = [0;0;0;0];
yd=lsim(sysc,ud,T);

Notes: The transpose of vector T is donne to unified dimensions for all the variables.

Related