0% found this document useful (0 votes)
2 views4 pages

Code Matlab

The document contains a series of answers to questions numbered 41 to 90, followed by a MATLAB function for simulating projectile motion under the influence of gravity and drag. It prompts the user for various inputs including mass, initial velocity, launch angle, and drag coefficient, and then calculates the trajectory equations. The function also allows for plotting the projectile's path for different drag coefficients.

Uploaded by

Thy Anh
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)
2 views4 pages

Code Matlab

The document contains a series of answers to questions numbered 41 to 90, followed by a MATLAB function for simulating projectile motion under the influence of gravity and drag. It prompts the user for various inputs including mass, initial velocity, launch angle, and drag coefficient, and then calculates the trajectory equations. The function also allows for plotting the projectile's path for different drag coefficients.

Uploaded by

Thy Anh
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/ 4

41b

42c

43a

44d

45c

46d

47c

48b

49b

50a

51b

52a

53b

54b

55a

56a

57c

58b

59a

60b

61b

62b

63a

64b

65a

66b
67d

68b

69a

70a

71b

72a

73a

74b

75b

76a

77c

78b

79c

80c

81a

82b

83c

84c

85d

86d

87a

88d

89b

90a
function THY
%% KHAI BÁO VÀ NH?P D? LI?U
syms m g v0 alpha h t time;
m = input('Nhap khoi luong cua vat m (kg)= ');
v0 = input('Nhap gia tri van toc ban dau cua vat v0 (m/s)
= ');
donvigoc = input('Chon don vi goc [(1).Radian hoac (2).
Degrees] : ');
if (donvigoc == 1)
alpha = input ('Nhap goc nem cua vat alpha (Radian) =
');
elseif (donvigoc == 2)
alpha= input ('Nhap goc nem cua vat alpha (Degrees) =
');
alpha = alpha*pi/180;
end
h = input('Nhap he so luc can moi truong h = ');
time = input('Nhap thoi gian bay cua vat t(s) = ');

%% HANG SO
g = 9.8;

%% TINH TOAN
x(t) = dsolve('m*D2x = -h*Dx','Dx(0) =
v0*cos(alpha)','x(0)= 0');
y(t) = dsolve('m*D2y = -m*g-h*Dy','Dy(0)=
v0*sin(alpha)','y(0)= 0');
disp('Nghiem phuong trinh vi phan la; ');
disp('x(t)=');
pretty(x(t));
disp('y(t)=');
pretty(y(t));

%% VE DO THI
figure ('name','Nem xien trong gia toc trong truong co luc
can' , 'color','white','numbertitle','off');
fplot(subs(x(t)),subs(y(t)),[0 time]);
xlabel('x(t)','FontSize',12,'FontWeight','bold','Color','r
');
ylabel('y(t)','FontSize',12,'FontWeight','bold','Color','r
');
grid on;
axis([0 inf 0 inf]);

%%CAC DO THI VOI HE SO LUC CAN KHAC NHAU


N = input('Nhap so voi gia tri h khac nhau ma ban muon la:
');
for i=1:1:N
disp(i); h = input('Nhap so gia tri h khac nhau ma ban
muon la: ');
x(t) = dsolve('m*D2x = -h*Dx','Dx(0) =
v0*cos(alpha)','x(0)= 0');
y(t) = dsolve('m*D2y = -m*g-h*Dy','Dy(0)=
v0*sin(alpha)','y(0)= 0');
figure ('name','Nem xien trong gia toc trong truong co luc
can' , 'color','white','numbertitle','off');
xlabel('x(t)','FontSize',12,'FontWeight','bold','Color','r
');
ylabel('y(t)','FontSize',12,'FontWeight','bold','Color','r
');
fplot(subs(x(t)),subs(y(t)),[0 time]);
grid on;
axis([0 inf 0 inf]);
hold on
end
%%KET THUC
disp('Well done');

You might also like