Creating a Function based on Time
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Viper224
am 7 Dez. 2016
Bearbeitet: Walter Roberson
am 7 Dez. 2016
As the title suggests I'm trying to create a function of time that computes lift and drag coefficients for the first 5 seconds and then what they are after 5 seconds. I don't have too much MatLab experience so I'm probably not doing this right. Can someone please help?
function[CL, CD, CP] = LiftandDrag(t, CLi, CDi)
t = 1:100;
CDi = 0.01; %Initial canopy Drag Coefficient
CLi = 0.0; %Initial canopy Lift Coefficient
if t < 5
CL = .2*t+CLi;
CD = 0.038*t+CDi; %drag coeffcient of chute
CP = 2; %drag of payload
elseif t > 5
CL = 1; %Inflated canopy Lift Coefficient
CD = .2; %Inflated canopy Drag Coefficient
CP = 2; %Payload Drag Coefficient
end
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 7 Dez. 2016
Bearbeitet: Walter Roberson
am 7 Dez. 2016
Vectorize. Logical indexing.
function [CL, CD, CP] = calcLiftAndDrag
t = 1:100;
CDi = 0.01; %Initial canopy Drag Coefficient
CLi = 0.0; %Initial canopy Lift Coefficient
[CL, CD, CP] = LiftandDrag(t, CLi, CDi);
function[CL, CD, CP] = LiftandDrag(t, CLi, CDi)
CL = zeros(size(t));
CD = zeros(size(t));
CP = zeros(size(t));
mask = t <= 5;
CL(mask) = .2*t(mask)+CLi;
CD(mask) = 0.038*t(mask)+CDi; %drag coeffcient of chute
CP(mask) = 2; %drag of payload
CL(~mask) = 1; %Inflated canopy Lift Coefficient
CD(~mask) = .2; %Inflated canopy Drag Coefficient
CP(~mask) = 2; %Payload Drag Coefficient
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Calculus finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!