Reputation: 1
I write code below but i find an error that I do not know what it is please help me the error is
Error using idmodel/sim (line 114) The simulation input data must be specified using an iddata object or a double matrix.
Error in Untitled (line 17) y = sim(sys,u);
clc;
clear all ;
close all;
A = [1 -0.5 0.06];
B = [5 -2];
C = [1 -0.2 0.001];
Ts = 1; %sample time
sys = idpoly(A,B,C,'Ts',1);
Range = [-1 1];
Band = [0 1];
u = stairs(idinput(100,'prbs',Band,Range)); %form a prbs input
opt1 = simOptions('AddNoise',true);
y = sim(sys ,u,opt1);
iodata = iddata(y,u,Ts);
na = 3; nb = 2; nc = 3; nk = 1;
me = armax(iodata,[na,nb,nc,nk]);
compare(iodata,me)
thank you very much
Upvotes: 0
Views: 75
Reputation: 667
Your input variable u
, should be a column vector, but with your code it is a graphics object, use class(u)
to check this. If you replace this line
u = stairs(idinput(100,'prbs',Band,Range)); %form a prbs input
with something like this:
u = [zeros(25, 1); ones(25, 1)]; % step input
Then the code no longer crashes.
Upvotes: 1