2017-01-09 10 views
-3

오류다음 MATLAB 코드를 디버깅하려면 어떻게해야합니까?

파일 : parameter_estimation_1.m 라인 : 8 칼럼 : 10

예기치 않은 MATLAB 식입니다.

작물까지 나는 다음과 같은 MATLAB 코드를 실행하면

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 

가이 코드는 모델의 매개 변수를 추정하기 위해 "est_vdv"라는 제목의 SIMULINK 모델과 협력하여 실행하도록되어 있습니다. 이 오류를 어떻게 처리해야합니까? 귀하의 제안에 대한

+2

당신은이 줄을 의미합니까? subplot (2,1,1), plot (tp, yp, 'k', t, y, 'ko');'세미 콜론 대신에 코마가 있습니다 –

+0

또는 하나 :'uu = 0.5 1 0.25 * randn (length (T), 1);'? –

+0

일반적으로 대부분의 스택 오버플로 사용자는 [물고기를 구걸하는] 질문이별로 없습니다 (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) - 직접 잡는 법을 배워야합니다 *,이 경우 자신의 코드를 디버깅하는 방법을 배워야합니다. –

답변

-1

감사합니다 친구, 나는 그것이

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

죄송합니다

를 있었어야, 5 라인 무엇이 잘못되었는지 알아낼 수 있었다, 그것은 잘못 오류가 8 줄 것을 지시했다 .