Plot of a function
Show older comments
I´ve created a script that calculates the speed and altitude of a rocket vertically lauched and i don´t know how to plot the aceleration during the flight. This is one of the functions that I want and I use it to create the movement equation
function acel=aceleracion(V,h,t)
alfa=0; delta=0;
if t>=0 & t<=tcomb1
acel=empuje(h,t)./(Wmisil-t.*gasto1) - ...
resistencia_aerodinamica(V,h,alfa,delta,t)./(Wmisil-t.*gasto1)...
-g ;
end
if t>tcomb1 & t<tcomb2
acel=empuje(h,t)./(Wmisil2-t.*gasto2) - ...
resistencia_aerodinamica(V,h,alfa,delta,t)./(Wmisil2-t.*gasto2)...
-g ;
end
if t>=tcomb2
acel=empuje(h,t)./(W3) - ...
resistencia_aerodinamica(V,h,alfa,delta,t)./(W3)...
-g ;
end
end
whit the main script I have acomplished the values of "V" (velocity) and "h" (altitude) and also a vector "tiempo" . The problem appears when I try to plot the aceleration like this
figure(3);
plot(tiempo, aceleracion(altura(:,2),altura(:,1),tiempo),'-b', 'LineWidth',1)
xlabel('t [s]', 'FontSize',11);
ylabel('a [ m / s^2 ]', 'FontSize',11);
axis([0,tfin(end),-2*9.8,2*9.8]);
where "altura" is a vector with the solutio.ns for V and h. Can you see what is wrong? thanks
Accepted Answer
More Answers (1)
Walter Roberson
on 10 Nov 2013
Your t is a vector.
An evaluated expression is true when the result is nonempty and contains all nonzero elements (logical or real numeric). Otherwise, the expression is false.
Categories
Find more on Image Arithmetic 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!