Grey Box Model code error
Show older comments
Hello everyone. So I am new to using the SSID toolbox and I'm getting some error codes when I run the script.(These are the two errors) "Error using iddata/greyest (line 40) When estimating a discrete time model, the sample time of the model must match that of the estimation data.
Error in Idgrey (line 31) model = greyest(data,model,opt);"
My code is as follows:
function [A,B,C,D] = System(c1,c2,c3,c4,Ts)
A = [0 1 0; 0 0 1; -(c4/c1) -(c3/c1) -(c2/c1)];
B = [0 ; 0; (1/c1)];
C = zeros(1,3);
D = zeros(1,1);
end
clear all; close all; clc
load DataNew2.mat
outdoor= DataNew2(:,1);
indoor = DataNew2(:,2);
data = iddata(indoor,outdoor,1,'Name','Temp Data');
data.OutputName = 'Indoor Temperature';
data.OutputUnit = 'Celcius';
data.InputName = 'Outdoor Temperature';
data.InputUnit = 'Celcius';
data.Tstart = 1;
data.TimeUnit = 'h';
c1 = 1;
c2 = 1.5;
c3 = 19;
c4 = 1.5;
model = idgrey('myfunc',{c1,c2,c3,c4},'d');
model.Structure.Parameters(1).Free = true;
model.Structure.Parameters(2).Free = true;
model.Structure.Parameters(3).Free = true;
model.Structure.Parameters(4).Free = true;
opt = greyestOptions('InitialState','estimate','Display','on');
opt.EnforceStability = true;
model = greyest(data,model,opt);
% b_est = model.Structure.Parameters(4).Value;
% [b_est,d_b_est] = getpvec(model,'free')
compare(data,model)
Just to explain somethings. DataNew2.mat is a 288 by 2 matrix of temperature data. I reference outdoor and indoor temperature to its corresponding columns.
Once I run the script and print "data" it says,
Time domain data set with 288 samples.
Sample time: 1 hours
Name: Temp Data
Outputs Unit (if specified)
Indoor Temperature Celcuis
Inputs Unit (if specified)
Outdoor Temperature Celcius
So I'm really not too sure where I'm getting an error. I have 4 coefficients that I need to be guessed. One of the errors is saying that my estimation data isn't the same size but I have no idea where to put the sample time to be 1 to 288 (because I have 288 data observations).
1 Comment
Ljuboslav Boskic
on 11 Jan 2018
Edited: Ljuboslav Boskic
on 11 Jan 2018
Answers (0)
Categories
Find more on MPC Design in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!