You are on page 1of 3

% Assignment No.

03
% Student Name: Zohaib
% BSAP, 8th Semester, section B
clc
clear all
close all
x=menu('Equations of Motion','1st Eq.','2nd Eq.','3rd Eq.');
if x==1;
disp('1st Eq. of Motion')
x1=menu('1st Eq.','vf','vi','a','t');
if x1==1;
vi=input('Enter initial velcoity = ');
a=input('Enter acceleration = ');
t=input('Enter the value of time = ');
vf=vi + a*t
fprintf('Finale Velocity%f\n',vf)

elseif x1==2;
vf=input('Enter Final velcoity = ');
a=input('Enter acceleration = ');
t=input('Enter the value of time = ');
vi = vf - a*t
fprintf('Initial velocity = %f\n',vi)

elseif x1==3;
vf=input('Enter Final velcoity = ');
vi=input('Enter Initial velocity = ');
t=input('Enter the valeu of time = ');
a = (vf - vi) /t
fprintf('Time will be = %f\n',a)

elseif x1==4;
vf=input('Enter Final velcoity = ');
vi=input('Enter Initial velocity = ');
a=input('Enter acceleration = ');
t = (vf - vi)/a
fprintf('Acceleration will be = %f\n',t)

end
elseif x==2;
disp('2nd Eq. of motion')
x2=menu('2nd Eq. of Motion','S','vi','t','a');
if x2==1;
disp('Finding Distance (S)')
vi=input('Enter the initial velocity = ');
t=input('Enter the value of time = ');
a=input('Enter the acceleration = ');
S=vi*t + (1/2)*a*t.^2;
fprintf('The Distance is %f \n',S)
elseif x2==2;
disp('Finding Initial velocity (vi)')
S=input('Enter the Distance = ');

1
t=input('Enter the value of time = ');
a=input('Enter the acceleration = ');
vi = (S - (1/2)*a*t.^2)/t ;
fprintf('The value of time is %f \n',vi)
elseif x2==3;
disp('Finding Time (t)')
S=input('The value of Distance = ');
vi=input('Enter the initial velocity is = ');
a=input('Ente value of acceleration = ');
syms('t')
eqn = a*t.^2 + 2*vi*t - 2*S == 0
S = solve(eqn);
fprintf('Time will be %f \n',S)
elseif x2==4;
disp('Finding Acceleration ')
S=input('Enter Distance = ');
vi=input('Enter initial velocity = ');
t=input('Enter the value of time = ');
a = (2*S - 2*vi*t)/t.^2 ;
fprintf('The value of acceleration will be %f \n',a)
end
elseif x==3;
disp('3rd Eq. of Motion')
x3=menu('Quantity of 3rd Eq. of motion','a','S','vf','vi');
if x3==1;
disp('Finding acceleration a')
S=input('Enter the value of Distance = ');
vf=input('Enter the Final Velocity = ');
vi=input('Enter the Initial velocity = ');

a = (vf.^2 - vi.^2)/(2*S);
fprintf('Acceleration will be %f \n',a)
elseif x3==2;
disp('Finding Distance')
a=input('Enter the value of acceleration = ');
vf=input('Enter the Final Velocity = ');
vi=input('Enter the Initial velocity = ');

S = (vf.^2 - vi.^2)/(2*a);
fprintf('The Value of Distance will be %f \n',S)
elseif x3==3;
disp('Finding Final Velocity')
a=input('Enter the value of acceleration = ');
vi=input('Enter the Initial velocity = ');
S=input('Enter the value of Distance = ');

vf = (sqrt(2*a*S + vi.^2)) ;
fprintf('Value of Final Velocity %f \n',vf)
elseif x3==4;
disp('Finding Initial velocity')
a=input('Enter the value of acceleration = ');
vf=input('Enter the Final velocity = ');
S=input('Enter the value of Distance = ');

2
vi = (sqrt( vf.^2-2*a*S )) ;

end

end

Published with MATLAB® R2017a

You might also like