Why do I get the error 'The number of inputs and outputs of the model must match that of the data.'?
24 次查看(过去 30 天)
显示 更早的评论
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
回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!