Plotting a function and it's derivative with multiple points of time
조회 수: 2 (최근 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에서 Number Theory에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!