why is my plot not showing anything

function BTLnhom11
clear;
close;
syms t v;
disp('Chon chieu duong huong len')
disp('Chon goc toa do tai mat dat');
disp('Phuong trinh dinh luat II Newton cho ten lua');
fprintf('\t\tm*dv/dt = -v0*dm/dt - mg\n');
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,t);
disp(y);
fprintf('Ten lua het nhien lieu tai thoi diem t= %0.2f s\n',t1);
fprintf('Tai t= %0.2f s ten lua khong con chuyen dong\n',t1);
fplot(y,[0 t1],'r');
title('Do thi bieu dien phuong trinh chuyen dong cua ten lua');
xlabel('Thoi gian t');
ylabel('Do cao(h)');
grid on;
I want to plot y, but it not working.

2 Comments

We would need to know the input values in order to test this.
the input values are:
m0= 300000
k=2000
v0=1200
y0=0

Sign in to comment.

 Accepted Answer

m0 = 300000;
k = 2000;
v0 = 1200;
y0 = 0;
BTLnhom11(m0, k, v0, y0)
Chon chieu duong huong len Chon goc toa do tai mat dat Phuong trinh dinh luat II Newton cho ten lua m*dv/dt = -v0*dm/dt - mg
v = 
Gia toc cua ten lua a=
Phuong trinh chuyen dong ten lua y =
Ten lua het nhien lieu tai thoi diem t= 150.00 s Tai t= 150.00 s ten lua khong con chuyen dong
ans = 
NaN
function BTLnhom11(m0, k, v0, y0)
syms t v;
disp('Chon chieu duong huong len')
disp('Chon goc toa do tai mat dat');
disp('Phuong trinh dinh luat II Newton cho ten lua');
fprintf('\t\tm*dv/dt = -v0*dm/dt - mg\n');
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,t);
disp(y);
fprintf('Ten lua het nhien lieu tai thoi diem t= %0.2f s\n',t1);
fprintf('Tai t= %0.2f s ten lua khong con chuyen dong\n',t1);
figure
fplot(real(y),[0 t1],'r');
title('real -- Do thi bieu dien phuong trinh chuyen dong cua ten lua');
xlabel('Thoi gian t');
ylabel('Do cao(h)');
grid on;
figure
fplot(imag(y),[0 t1],'r');
title('imag -- Do thi bieu dien phuong trinh chuyen dong cua ten lua');
xlabel('Thoi gian t');
ylabel('Do cao(h)');
grid on;
limit(y, t, t1)
end

1 Comment

syms m0 k t
term = log(m0/(m0 - k*t))
term = 
int(term, t)
ans = 
Now look at the integral: it has t times the initial expression, but it also has log() of the negative of the denominator of the original expression -- the denominator m0 - k*t in the first expression becomes log(k*t - m0) in the integral. But as long as m0 is positive and m0-kt is positive, then the first one is log() of a positive number, but the second one is log() of a negative number. So there is inherently a complex result for the integral for positive m0, k and m0 > k*t. (And you build your k to be m0 >= k*t)

Sign in to comment.

More Answers (0)

Products

Release

R2018a

Tags

Community Treasure Hunt

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

Start Hunting!