Borrar filtros
Borrar filtros

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

2 visualizaciones (últimos 30 días)
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.

Respuestas (1)

Walter Roberson
Walter Roberson el 28 de En. de 2021
Editada: Walter Roberson el 28 de En. de 2021
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.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by