equation and its derivative, wrong with using * please help
Show older comments
t = [0:8];
Position = 8-(4*t.^3)*exp(-0.4*t)+2*t.^2
Velocity = (-12*t.^2)*(exp(-0.4*t))+(-4*t.^3)*(-0.4)*(exp(-0.4*t))+(4*t)
Acceleration = -12*(t.^2)*(exp(-0.4*t))+ (1.92*t.^2)*exp(-0.4*t)+4
plot(t, Position)
plot(t, Velocity)
plot(t, Acceleration)
% so is the e^something = exp(something) right? I just want to make sure the error mostly in using * but I don't know I tried using parenthesis
1 Comment
The error using * is simple: you are using the wrong command. To know what the correct command is you really need to read and understand this:
Answers (1)
Star Strider
on 1 Nov 2017
You need to vectorise the multiplications (replace ‘*’ with ‘.*’) as well as the exponentiations:
t = 0:8;
Position = 8-(4*t.^3).*exp(-0.4*t)+2*t.^2;
Velocity = (-12*t.^2).*(exp(-0.4*t)) + (-4*t.^3)*(-0.4).*(exp(-0.4*t))+(4*t);
Acceleration = -12*(t.^2).*(exp(-0.4*t)) + (1.92*t.^2).*exp(-0.4*t)+4;
figure(1)
plot(t, Position)
hold on
plot(t, Velocity)
plot(t, Acceleration)
hold off
legend('Position', 'Veolcity', 'Acceleration', 'Location','NW')
grid
I also tweaked your plot call.
Categories
Find more on Biotech and Pharmaceutical 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!