Plotting a function and it's derivative with multiple points of time

1 回表示 (過去 30 日間)
David Scidmore
David Scidmore 2021 年 1 月 28 日
コメント済み: David Scidmore 2021 年 1 月 28 日
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 件のコメント
Matt J
Matt J 2021 年 1 月 28 日
I have tried to use .* it just returns the same error message.
Not for me.

サインインしてコメントする。

回答 (1 件)

Walter Roberson
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)
phiddot_s = 
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.
  1 件のコメント
David Scidmore
David Scidmore 2021 年 1 月 28 日
Ahhh I was just using it in the wrong place. Thanks

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by