-3

The error

File: parameter_estimation_1.m Line: 8 Column: 10

Unexpected MATLAB expression.

crops up when I run the following MATLAB code:

T = 0:0.25:5; % time vector (row)
T = T'; % time vector (column)
seed = [3;0.5]; % seed for noise generation
randn('state',seed); % using the same seed each time
uu = 0.5 1 0.25*randn(length(T),1); % mean of 0.5 with variance
% of 0.25
U = 2*round(uu)-1; % creates PRBS with -1 and 1 values %
sim('est_vdv'); % runs simulation of linear van de vusse % diagram
figure(1); % plot input-output data
subplot(2,1,1),plot(tp,yp,'k',t,y,'ko');
xlabel('time, min'), ylabel('y')
title('PRBS estimation example')
subplot(2,1,2),plot(tp,up,'k'); xlabel('time, min'),ylabel('u')
axis([0 5 -1.1 1.1])
% % generate phi matrix for estimation
for j = 4:22;
phi(j-3,:) = [y(j-2) y(j-3) u(j-2) u(j-3)];
end
%
theta = inv(phi'*phi)*phi'*y(3:21) % estimate parameters
num = [theta(3) theta(4)]; % numerator of discrete transfer function
den = [1 -theta(1) -theta(2)]; % denominator of discrete transfer function
sysd = tf(num,den,0.25) % create discrete tf object
tzero(sysd) % calculate zeros
pole(sysd) % calculate poles
syszpk = zpk(sysd) % zero-pole-k form

This code is supposed to run in tandem with a SIMULINK model titled "est_vdv" to estimate the parameters of a model. How should I deal with this error?

Community
  • 1
  • 1
biswajit
  • 15
  • 7
  • 2
    you mean this line ?`subplot(2,1,1),plot(tp,yp,'k',t,y,'ko');` There is an coma instead of a semi colon – Ander Biguri Jan 09 '17 at 10:21
  • or this one: `uu = 0.5 1 0.25*randn(length(T),1);`? (missing brackets) – Rody Oldenhuis Jan 09 '17 at 11:02
  • In general, most Stack Overflow users are not very fond of questions [begging for fish](https://en.wiktionary.org/wiki/give_a_man_a_fish_and_you_feed_him_for_a_day;_teach_a_man_to_fish_and_you_feed_him_for_a_lifetime) -- you should learn to *catch your own*, in this case by learning to debug your own code. – Rody Oldenhuis Jan 09 '17 at 11:08
  • For scripts like these, just step through the code line by line until the error pops up. Then, if it's still not clear what the problem is, break up the erroring line of code into individual parts and execute each part, until the error pops up. Then, if it's *still* not clear what's the problem, consult a manual on each of the constituent functions. – Rody Oldenhuis Jan 09 '17 at 11:08
  • Rody, if you don't wanna help....stay away. There are many others who will be more than happy to help. – biswajit Jan 10 '17 at 11:18

1 Answers1

-1

Thanks Friends for your suggestions, I have been able to figure out what went wrong with the 5th line, it should have been

uu=0.5+0.25.*randn(length(T),1)

Sorry, it was wrongly indicated that the error was in the 8th line.

biswajit
  • 15
  • 7