User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Legacy and Other Languages section within the Software Development category of DaniWeb, a massive community of 374,193 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,560 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Legacy and Other Languages advertiser:
Views: 879 | Replies: 3
Reply
Join Date: Apr 2008
Posts: 1
Reputation: tinazmail is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
tinazmail tinazmail is offline Offline
Newbie Poster

Matlab Help

  #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 1:29 am. Reason: added code tags
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Aug 2005
Location: near St Louis, Missouri, USA
Posts: 10,184
Reputation: Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of 
Rep Power: 34
Solved Threads: 822
Moderator
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Most Valuable Poster

Re: Matlab Help

  #2  
Apr 20th, 2008
what programming language is that ? Need to move this thread to the appropriate board for that language.
'Politics' is made up of two words, 'poli,' which is Greek for 'many,' and 'tics,' which are blood-sucking insects.
- Gore Vidal
Being ignorant is not so much a shame as being unwilling to learn. - Benjamin Franklin
Reply With Quote  
Join Date: Apr 2006
Location: Canada
Posts: 4,394
Reputation: John A is a glorious beacon of light John A is a glorious beacon of light John A is a glorious beacon of light John A is a glorious beacon of light John A is a glorious beacon of light 
Rep Power: 15
Solved Threads: 260
Moderator
Staff Writer
Featured Blogger
John A's Avatar
John A John A is offline Offline
Vampire Moderator

Re: Matlab Help

  #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 1:32 am.
tuxation.com - Linux articles, tutorials, and discussions
Reply With Quote  
Join Date: Jan 2007
Location: India
Posts: 186
Reputation: shouvik.d is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 6
shouvik.d's Avatar
shouvik.d shouvik.d is offline Offline
Junior Poster

Re: Matlab Help

  #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  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb Legacy and Other Languages Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the Legacy and Other Languages Forum

All times are GMT -4. The time now is 5:00 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC