Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

m

-O

’X=Gtcemt

-CeXe
m

m(Vo cos)

mVo cole

e Cm

Oxt)

(02+Cn)
cyn

-ctm C

C Jto

74- Vo ino t yc
CHANAKYAA

Data t2

%) (t-e")
1

(a) At
átaint (ocafn
mut
in ciiula hi ofisn.

k= cont


C Co incdes
oith c'|

(b), m

m
CHANAKYAA
fy- Pofe nfiat funetion,4- poeuta
15
Cnngy?

+ka

’ 49 e k (la -d.)2
2
CHANAKYAA
’ -c ( t A

= t
tAzk) =
dy t ade

) f=-fx)?
Problem_9 :

cla
clf

figure(1)

npoints = 100; tend=2;


tspan = linspace(0,tend,npoints);

r0 = [0;0];
speed0 = 1; launchangle = pi/4;
v0 = speed0 * [cos(launchangle);sin(launchangle)];
z0= [r0;v0];

[t, zarray] = ode45(@myrhs, tspan, z0);

x = zarray(:,1);
y = zarray(:,2);

shg

%%%%%%%%%%%%%%%%
%Animation

%plot(x,y);
for i= 1:npoints

plot(x,y);
grid on ;
hold on;
axis equal % !!!!!!!
plot(x(i),y(i),'.','MarkerSize',30)

pause(.01);
%shg
hold off;
end
%shg

fprintf('x = %f, y = %f', x(npoints), y(npoints));

%%%%%%%%%%%%%%%%%

function zdot = myrhs(~, z)


%Right-Hand-Side Function
v = z(3:4);
c=1; m=1; g=1;
j = [0;1];

F = -m*g*j - c*v*norm(v);

rdot = v;
vdot = F/m;

zdot = [rdot;vdot];
end

Problem_12(a) :

cla
clf

figure(1)

npoints = 100; tend=2;


tspan = linspace(0,tend,npoints);

r0 = [0;0];
speed0 = 1; launchangle = pi/4;
v0 = speed0 * [cos(launchangle);sin(launchangle)];
z0= [r0;v0];

[t, zarray] = ode45(@myrhs, tspan, z0);

x = zarray(:,1);
y = zarray(:,2);

shg

%Animation

%plot(x,y);
for i= 1:npoints

plot(x,y);
grid on ;
hold on;
axis equal % !!!!!!!
plot(x(i),y(i),'.','MarkerSize',30)
pause(.01);
%shg
hold off;
end
%shg

fprintf('x = %f, y = %f', x(npoints), y(npoints));

%%%%%%%%%%%%%%%%%

function zdot = myrhs(~, z)


%Right-Hand-Side Function

v = z(3:4);
c=1; m=1; g=1;
j = [0;1];

F = -m*g*j - c*v*norm(v);

rdot = v;
vdot = F/m;

zdot = [rdot;vdot];
end

You might also like