Reply

Join Date: Apr 2008
Posts: 1
Reputation: tinazmail is an unknown quantity at this point 
Solved Threads: 0
tinazmail tinazmail is offline Offline
Newbie Poster

Matlab Help

 
0
  #1
Apr 20th, 2008
Hello everyone, I have a Matlab program that I got and want to run it on my PC. It gives me errors even though I'm 100% sure of the program and the data entry.My problem is in the function calling somewhere please help. My final is due this monday .
I have attached the code below, thank you for all the support.

%  Program name:  zerodynamics_tracking_comparison_Ex6_6_5_main
%  The purpose of this example is to compare the tracking performance of a
%  fully and partially linearizable system resulting from different choices
%  of the output equations.
clc, clear all, close all, format short g
global g K KK ro rro ncon
%%  Normal-form system matrices in controllable canonical form
Ac=[0 1; 0  0];						%  Controllable Ac in z-domain
Bc=[0;  1];						%  Controllable Bc in z-domain
Cc=[1  0];						%  Output matrix
D=0;							%   Throughput matrix
g=[0; 1];						%  g(x) matrix in xdot=f (x) +g (x) u
%%  Pole placement to design for normal form
zeta=0.7;  wn=6; wd=wn*sqrt (1-zeta^2)
p=[-zeta*wn+j*wd   -zeta*wn-j*wd]     					%  Chosen complex poles
K=place(Ac, Bc, p)					%  Poles placement gain matrix K
Acl=Ac-Bc*K;					%  CL system matrix in z-domain
%  Step response of y(t)=x1 (t) in the z-coordinates with r(t)=ro  (rad)
ro=8;
t=0: 0.01:2;
step (Acl,Bc*K(1)*ro,Cc,D,1,t) ;grid			%  Get y(t)=x1 (t) step response statistics
title ('Step response of fully linearizable system:  \rho=2=n:  y(t)=x_1(t)', 'fontsize',12)
xlabel ('t', 'fontsize',12), ylabel ('y(t)=x_1(t) ', 'fontsize',12)
%%  Case 1:  Step responses of fully linearizable system
ro=8;							%  Step input r(t)=ro
x0=[0; 0.2];						%  Initial condition of x
t=0:0.01:2;
ncon=1;						%  Case 1
[t,x]=ode23 ('zerodynamics_tracking_comparison_Ex_6_6_5_fn', t, x0);
figure,plot(t,x(:,1),t,x(:,2), '--', 'linewidth',1.5),grid
xlabel('t (sec) ', 'Fontsize',12)
title('Step response of fully linearizable system:\rho=2:x_1(t)==>ro=8,x_2(t)','fontsize',12)
legend('x_1(t)', 'x_2(t) ', 'location', 'best')
%%  Case 2:  Step responses of normal form – note that this system is not robust
rro=2;
KK=4.2;						%  Control gain = closed-loop pole
t=0:0.01:6;
x0=[0; 0.2];						%  Initial condition of x
ncon=2;						%  Case 2
[t,x]=ode23('zerodynamics_tracking_comparison_Ex_6_6_5_fn',t,x0);
figure,plot(t,x(:,1),t,x(:,2), '—','linewidth',1.5)grid
xlabel('t(sec)', 'Fontsize',12)
title('Step responses of normal form:  \rho=1: x_1(t), x_2(t) ==>r(t)=2',
'fontsize',12)
legend('x_1(t) '',x_2(t) ', 'location','best')
n=2*[4.2]; d = [1 4.2];	%  Get the settling time of Case 2
figure,step(n,d),grid


%  Function name:  zerodynamics_tracking_comparison_Ex6_6_5_fn
%  function xdot=zerodynamics_tracking_comparison_Ex_6_6_5_fn
%  The purpose of this example is to compare the tracking performance of a
%  fully and partially linearizable system resulting from different choices
%  of the output equations.

function xdot=zerodynamics_tracking_comparison_Ex_6_6_5_fn(t,x)

global g K KK ro rro  ncon   

f=[-x(1)+x(2)^3;-x(2)];
alpha=x(1)-4*x(2)^3; 
Dx=3*x(2)^2;					%  Decoupling matrix

%%  Case 1:  Step input for fully linearizable system
if ncon==1						%  Case 1

	z=[x(1);-x(1)+x(2)^3];			%  Transformation z=T(x)
	v=-K(1)*z(1)+K(2)*z(2)+K(1)*ro;	%  z-domain linear tracking control law
	u=inv(Dx)*(-alpha+v);	%  Linearizing feedback tracking control law
else							%  Case 2

%%  Case 2:  Step input for normal form
             alpha=-x(2);
             Dx=1;
             v=-KK*(x(2)-rro);
             u=inv(Dx)*(-alpha+v); %  Linearizing feedback tracking control law

end

      xdot=f+g*u;
Last edited by John A; Apr 20th, 2008 at 2:29 am. Reason: added code tags
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,407
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1468
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: Matlab Help

 
0
  #2
Apr 20th, 2008
what programming language is that ? Need to move this thread to the appropriate board for that language.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 5,051
Reputation: John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold John A is a splendid one to behold 
Solved Threads: 332
Team Colleague
John A's Avatar
John A John A is offline Offline
Vampirical Lurker

Re: Matlab Help

 
1
  #3
Apr 20th, 2008
I added code tags, but I see it didn't help much. Also, we don't have a category for the Matlab programming language, so instead I've moved it to "legacy and other languages".
Last edited by John A; Apr 20th, 2008 at 2:32 am.
"Technological progress is like an axe in the hands of a pathological criminal."

All my posts may be freely redistributed under the terms of the MIT license.
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 200
Reputation: shouvik.d is an unknown quantity at this point 
Solved Threads: 6
shouvik.d's Avatar
shouvik.d shouvik.d is offline Offline
Posting Whiz in Training

Re: Matlab Help

 
0
  #4
May 6th, 2008
What was the error actually. This is a .m script and better if you post the error message.
Regards
Shouvik
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Legacy and Other Languages Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC