# Determine the rocket's equation of motion

19 views (last 30 days)
Vinh San Phan Vo on 18 Oct 2021
Commented: Vinh San Phan Vo on 8 Nov 2021 at 15:26
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 CommentsShowHide 1 older comment
David Goodmanson on 18 Oct 2021
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 "

Sulaymon Eshkabilov on 18 Oct 2021
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');
...
Vinh San Phan Vo on 8 Nov 2021 at 15:26
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)

R2017b

### Community Treasure Hunt

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

Start Hunting!