フィルターのクリア

error while using iddata

6 ビュー (過去 30 日間)
arash rad
arash rad 2021 年 1 月 8 日
コメント済み: arash rad 2021 年 1 月 10 日
Hi i wrote the code below but when i run it i face two errors that i dont get it can anyone help me
Error using iddata/numArgumentsFromSubscript (line 8) The syntax "Data{...}" is not supported. Use the "getexp" command to extract individual experiments from an IDDATA object.
Error in arma (line 29)
plot(t,yhat1{1}.y,'--',t,y);
I have this two erros please help me
Thanks
%% Generate the data
N = 250;
Ts = 1;
u_var = 1;
noise_var = 1;
a = [1 -1.5 0.7];
b = [0 1 .5]; c = [1 -1 0.2];
u = sign(randn(2*N,1))*sqrt(u_var);
v = randn(2*N,1);
M = idpoly(a,b,c,1,1,noise_var,Ts);
y = sim(M,[u v]);
uv = u(N+1:end);
vv = v(N+1:end);
yv = y(N+1:end);
u = u(1:N);
v = v(1:N);
y = y(1:N);
DATe = iddata(y,u,Ts); DATv = iddata(yv,uv,Ts);
DATe1 = get(DATe); DATv1= get(DATv)
%% Identification
na = 2; nb = 2; nc = 2;
theta_pem = armax(DATe,[na nb nc 1]); % ARMAX using PEM
%% Compare the measured output and the model output
[yhat1,fit1] = compare(DATe,theta_pem);
[yhat2,fit2] = compare(DATv,theta_pem);
t = 1:N;
figure;
subplot(2,1,1);
plot(t,yhat1{1}.y,'--',t,y);
legend('model','measured');
title('Comparison on estimation data set','FontSize',16);
ylabel('y');xlabel('t');
subplot(2,1,2);
plot(t,yhat2{1}.y,'--',t,yv);
legend('y2','y');
legend('model','measured');
title('Comparison on validation data set','FontSize',16);
ylabel('y');xlabel('t');

採用された回答

Walter Roberson
Walter Roberson 2021 年 1 月 8 日
Is there a reason you are not using
plot(yhat1)
??
But if you insist...
plot(t, getexp(yhat1,1).y, '--', t, y);
  3 件のコメント
Walter Roberson
Walter Roberson 2021 年 1 月 9 日
Please try this code and see what you get.
%% Generate the data
N = 250;
Ts = 1;
u_var = 1;
noise_var = 1;
a = [1 -1.5 0.7];
b = [0 1 .5]; c = [1 -1 0.2];
u = sign(randn(2*N,1))*sqrt(u_var);
v = randn(2*N,1);
M = idpoly(a,b,c,1,1,noise_var,Ts);
y = sim(M,[u v]);
uv = u(N+1:end);
vv = v(N+1:end);
yv = y(N+1:end);
u = u(1:N);
v = v(1:N);
y = y(1:N);
DATe = iddata(y,u,Ts); DATv = iddata(yv,uv,Ts);
DATe1 = get(DATe); DATv1= get(DATv)
DATv1 = struct with fields:
Domain: 'Time' Name: '' OutputData: {[250×1 double]} OutputName: {'y1'} OutputUnit: {''} InputData: {[250×1 double]} InputName: {'u1'} InputUnit: {''} Period: {[Inf]} InterSample: {'zoh'} Ts: {[1]} Tstart: {[]} SamplingInstants: {[250×0 double]} TimeUnit: 'seconds' ExperimentName: {'Exp1'} Notes: {} UserData: []
%% Identification
na = 2; nb = 2; nc = 2;
theta_pem = armax(DATe,[na nb nc 1]); % ARMAX using PEM
%% Compare the measured output and the model output
[yhat1,fit1] = compare(DATe,theta_pem);
[yhat2,fit2] = compare(DATv,theta_pem);
t = 1:N;
figure;
subplot(2,1,1);
plot(t, getexp(yhat1,1).y, '--', t, y);
legend('model','measured');
title('Comparison on estimation data set','FontSize',16);
ylabel('y');xlabel('t');
subplot(2,1,2);
plot(t, getexp(yhat2,1).y, '--', t, yv);
legend('y2','y');
legend('model','measured');
title('Comparison on validation data set','FontSize',16);
ylabel('y');xlabel('t');
arash rad
arash rad 2021 年 1 月 10 日
thank you very much

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSmoothing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by