Code Matlab
Code Matlab
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]);