Determine the rocket's equation of motion

16 次查看(过去 30 天)
Can you please help me find an error in this code below. I can't figure it out. I have an error as the picture below
syms t
disp('Chon chieu duong huong len')
disp('Goc toa do tai mat dat');
disp('Phuong trinh dinh luat II Newton cho ten lua');
disp('m*dv/dt = -v0*dm/dt - mg');
k=input('Nhap toc do dot nhien lieu dm/dt = ');
m0=input('Nhap khoi luong ban dau cua ten lua m0 = ');
y0=input('Nhap vi tri ban dau cua ten lua y0 = ');
v0=input('Nhap van toc day khi cua ten lua v0 = ');
g=9.81;
v=v0*log(m0/(m0-k*t))-g*t;
t1=m0/k;
disp('Gia toc cua ten lua a=');
a=diff(v,1);
disp(a);
disp('Phuong trinh chuyen dong ten lua y = ');
y=y0+int(v);
disp(y);
disp(‘Ten lua het nhien lieu tai thoi diem t=’);
disp(t1);
disp(‘Tai thoi diem nay ten lua da ra ngoai vu tru va khong con chuyen dong);
ezplot(t,y);
title('Do thi bieu dien phuong trinh chuyen dong cua ten lua’);
xlabel('Thoi gian t');
ylabel('Vi tri y');
grid on;
end
  2 个评论
David Goodmanson
David Goodmanson 2021-10-18
编辑:David Goodmanson 2021-10-18
Hi VP
it looks like maybe you are using the ` symbol (hard to see here but on my keyboard it's on the upper left and the capital of the key is ~), rather than the single quote ' which on my keyboard is two keys to the right of L with the capital of the key being "

请先登录,再进行评论。

回答(1 个)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2021-10-18
In your code, you need to make some corrections, e.g.:
...
disp(t1);
disp('Tai thoi diem nay ten lua da ra ngoai vu tru va khong con chuyen dong');
t = 0:t1;
Y = eval(vectorize(y),t);
% plot(t, real(Y), 'r', t, imag(Y),'b')
plot(t, abs(Y), 'k-', 'linewidth', 2) % Because the values of y(t) can be complex. Thus, abs value is taken or you can plot real vs. imag.
title('Do thi bieu dien phuong trinh chuyen dong cua ten lua');
...
  1 个评论
Vinh San Phan Vo
can you please tell me why do u use this code please, i can't understand it hic :"(
% plot(t, real(Y), 'r', t, imag(Y),'b')
plot(t, abs(Y), 'k-', 'linewidth', 2)

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

标签

产品


版本

R2017b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by