•
•
•
•
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 429,759 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,954 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: Programming Forums
Views: 995 | Replies: 3
![]() |
•
•
Join Date: Apr 2008
Posts: 1
Reputation:
Rep Power: 0
Solved Threads: 0
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.
. 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
•
•
Join Date: Aug 2005
Location: near St Louis, Missouri, USA
Posts: 11,245
Reputation:
Rep Power: 38
Solved Threads: 938
what programming language is that ? Need to move this thread to the appropriate board for that language.
<<Freelance Programmer>> << Hobby Site>>
![]() |
•
•
•
•
•
•
•
•
DaniWeb Legacy and Other Languages Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- MatLab Forum? (DaniWeb Community Feedback)
- Translating from Matlab to C (C)
- matlab program help (Legacy and Other Languages)
- Matlab - figure caption (Computer Science and Software Design)
- Contaminating signals for testing filters on MATLAB (Computer Science and Software Design)
- translation of Pascal script into matlab (Pascal and Delphi)
- Building D.L.L in Matlab (Visual Basic 4 / 5 / 6)
Other Threads in the Legacy and Other Languages Forum
- Previous Thread: J# invalid paramater at runtime
- Next Thread: How do I set up and use a "whitelist" for forms?



Linear Mode