why is my plot not showing anything
3 views (last 30 days)
Show older comments
Quang Nguyen
on 3 Dec 2021
Commented: Walter Roberson
on 3 Dec 2021
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
Accepted Answer
Walter Roberson
on 3 Dec 2021
Edited: Walter Roberson
on 3 Dec 2021
m0 = 300000;
k = 2000;
v0 = 1200;
y0 = 0;
BTLnhom11(m0, k, v0, y0)
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
Walter Roberson
on 3 Dec 2021
syms m0 k t
term = log(m0/(m0 - k*t))
int(term, t)
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)
More Answers (0)
See Also
Categories
Find more on Nonlinear Dynamics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!