Plotting a function and it's derivative with multiple points of time
1 次查看(过去 30 天)
显示 更早的评论
I am working on trying to plot the perturbation roll angle from steady state and have the following.
clear all
clc
L_phi = -2.729;
L_sigma_a = -43.692;
sigma_a = -3;
beta = L_sigma_a./L_phi*sigma_a;
lambda = -L_phi;
tau = 1/L_phi;
t = 0:0.01:5;
phidot = beta*(1-exp(lambda*t));
phiddot = 2.279*phidot*phidot- 43.692*sigma_a*phidot;
figure(1)
plot(t,phidot)
title('phidot vs time')
xlabel('time in seconds')
ylabel('perturbation roll angle in degrees')
The error message(s) I get is
Incorrect dimensions for matrix multiplication. Check that the number of columns in the first matrix matches the number of
rows in the second matrix. To perform elementwise multiplication, use '.*'.
Error in HW1MAE503 (line 21)
phiddot = 2.279*phidot*phidot- 43.692*sigma_a*phidot;
I have tried to use .* it just returns the same error message. Considering I'm multiplying each aspect of T by the same singuar value this doesn't make sense to me.
I believe that the Error in line 21 is because it has no value to access.
So my focus here is on the 501 time points and how to record that so I can plot.
If you could also tell me how to add units to the axis that'd be cool, but not needed as I'm okay with the label.
1 个评论
回答(1 个)
Walter Roberson
2021-1-28
编辑:Walter Roberson
2021-1-28
L_phi = -2.729;
L_sigma_a = -43.692;
sigma_a = -3;
beta = L_sigma_a./L_phi*sigma_a;
lambda = -L_phi;
tau = 1/L_phi;
t = 0:0.01:5;
phidot = beta*(1-exp(lambda*t));
phiddot = 2.279.*phidot.*phidot- 43.692.*sigma_a.*phidot;
figure(1)
plot(t, phidot)
title('phidot vs time')
xlabel('time in seconds')
ylabel('perturbation roll angle in degrees')
plot(t, phiddot)
title('phiddot vs time');
syms t
phidot_s = beta*(1-exp(lambda*t));
phiddot_s = diff(phidot_s, t)
fplot(phiddot_s, [0 5]);
title('phiddot vs time, symbolic computation')
This suggests that your formula for phiddot is incorrect. You have exp(t) kind of function, and the derivative of that is not going to be t^2 - t kind of function.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Characters and Strings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!