equation and its derivative, wrong with using * please help
显示 更早的评论
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 个评论
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:
回答(1 个)
Star Strider
2017-11-1
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.
类别
在 帮助中心 和 File Exchange 中查找有关 Biotech and Pharmaceutical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!