MATLAB Answers

Ben25
0

Why do I get the error 'The number of inputs and outputs of the model must match that of the data.'?

Ben25
さんによって質問されました 2019 年 6 月 19 日
最新アクティビティ Ben25
さんによって コメントされました 2019 年 6 月 19 日
I am attempting to run a nonlinear grey box estimation on a defined ODE function, and I keep recieving the same error, no matter what I change. I don't see where the problem comes from. I have tried to change the input, but that has not worked. Here are the three files:
%6-11-19
%u = [u0*sin(w*t); u0*w*cos(w*t)];
function [dx, y] = DOF1damped(t, x, u, w, u0, m, k, c)
y = [x(1);x(2)];
dx = [x(2) ;((-k/m).*x(1) - (c/m).*x(2) + (k/m).*(u0*sin(w*t)) + (c/m).*(u0*w*cos(w*t)))];
end
_
%6-12-19
clear
close all
clc
u0 = 1; %amplitude ()
w = 1; %hz
m = 0.85048569375; %kg
k = 356.9085; % N/m
c = 10; %N/m*s
tspan = [0 10];
t = [0:.1:10];
u = [u0*sin(w*t); u0*w*cos(w*t)];
x0 = [0;0];
[t, x] = ode45(@(t,x)DOF1damped(t, x, u, w, u0, m, k, c), tspan, x0);
data = iddata(x, t, .1);
plot(t, x)
_
filename = 'DOF1damped';
Order = [2 0 2];
u0 = 1; %amplitude ()
w = 1; %hz
m = 0.85048569375; %kg
k = 356.9085; % N/m
c = 10; %N/m*s
Parameters = {u0,w,m,k,c};
InitialStates = [0; 0];
Ts = 0;
nlgr = idnlgrey(filename, Order, Parameters, InitialStates, Ts, 'Name','DOF1grey');
nlgr = setinit(nlgr, 'Fixed', {false false}); % Estimate the initial states.
setpar(nlgr,'Fixed',{true true true true false});
opt = nlgreyestOptions('Display', 'on');
nlgr = nlgreyest(data,nlgr,'Display','Full');
c_est = nlgr.Parameters(5).Value;
[nonlinear_c_est, dnonlinear_c_est] = getpvec(nlgr,'free')
compare(data,nlgr)
Thanks for any help

  2 件のコメント

@Ben Trinkle: please show the complete error message. This means all of the red text.
Ben25
2019 年 6 月 19 日
Here's the full error
>> DOF1grey
Error using iddata/nlgreyest (line 59)
The number of inputs and outputs of the model must match that of the data.
Error in DOF1grey (line 21)
nlgr = nlgreyest(data,nlgr,'Display','Full');

サインイン to comment.

0 件の回答


Translated by