0% found this document useful (0 votes)
49 views5 pages

Matlab Control Systems

Uploaded by

Akerke Khamar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
49 views5 pages

Matlab Control Systems

Uploaded by

Akerke Khamar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Exercise 1

Task 1
Example 1

function dvdt = cruise_speed(t,v)


M = 750;

B = 30;

Fa = 300;

dvdt = Fa/M-B/M*v;
end

v0 = 0;
[t,v] = ode45('cruise_speed', [0,125], v0);
plot (t,v); grid on;
title ('cruise speed time response to a constant fraction force')
Example 2

function dXdt=mass_spring(t, X)

%flow rate

M=750; %(Kg)

B=30; %( Nsec/m)

Fa=300; %N

K=15; %(N/m)

r=1;
dXdt(1,1)=X(2);

dXdt(2,1)=-B/M*X(2)-K/M*X(1)^r+Fa/M;
end

X0=[0; 0]; %(initial speed and position)


options = odeset('RelTol',[1e-4 1e-4],'AbsTol',[1e-5 1e-5],'Stats','on');
[t,X] = ode45('mass_spring', [0 200],X0);
plot (t,X)
Task 2
When r=2

When r=3
Exercise 2

function dydt=mass_spring(t, y)

%flow rate

M=10; %(Kg)

B=0.5; %( Nsec/m)

Fa=1; %N

K=1; %(N/m)

dydt(1,1)=y(2);

dydt(2,1)=-B/M*y(2)-K/M*y(1)+Fa/M;
end

y0=[0,0];

[t,y] = ode45('mech_systems', [0,200],y0);


plot (t,y);
Summary
Matlab helps to solve ODEs of one, two or even more degrees. Creating functions for ODE of
first order was easiest part as function defining was given in matlab library. Method used to
solve differential equations of second and higher order in the program requires addition of
another variable function. For example, Dy/dt = y2 and D2y/dt2= Dy2/dt. Such method is used
when solving mass spring problems in advanced control systems.

You might also like