I am currently making a velocity vs time plotting app for an object that is falling with drag. I have worked out the function for it using a bit of calculus and am now trying to plot it. I have plotted it in demos with some values that I preprepared and gotten values od velocity much greater than 1 m/s (which is what I was expecting). However, when I tried to input the same values into my app, to plot them, on my plot the values never exceeded 1. This made me think that MATLAB is somehow scaling my y axis to make all the values plot relative to 1 (which is seemingly the equivalent of the terminal velocity). I tried using,
ylim([0 n]);
to fix this, but that didnt change anything. Here is my code:
function startupFcn(app)
app.MaxMassEditField.Value = 100;
app.AreaEditField.Value = 1;
app.DragCoefficientEditField.Value = 1;
app.gEditField.Value = 1;
app.MediumDensitryEditField.Value = 1;
app.MassSlider.Limits = [10^(-7), app.MaxMassEditField.Value];
Area = app.AreaEditField.Value;
Cd = app.DragCoefficientEditField.Value;
g = app.gEditField.Value;
density = app.MediumDensitryEditField.Value;
mass = app.MassSlider.Value;
time = linspace(0, 100, 10000);
exponent = exp(2*sqrt((g*Area*density*Cd)/(2*mass))*time);
coefficeint = -sqrt((2*mass*g)/(density*Area*Cd));
velocity = coefficeint * (1-exponent)./(1+exponent);
plot(app.UIAxes, time, velocity)
ylim([0 100]);
end
(^for startup function)
Area = app.AreaEditField.Value;
Cd = app.DragCoefficientEditField.Value;
g = app.gEditField.Value;
density = app.MediumDensitryEditField.Value;
mass = app.MassSlider.Value;
app.MassSlider.Limits = [10^(-7), app.MaxMassEditField.Value];
time = linspace(0, 100, 1000);
exponent = exp(2*sqrt((g*Area*density*Cd)/(2*mass))*time);
velocity = - (1-exponent)./(1+exponent);
plot(app.UIAxes, time, velocity);
ylim([0 8]);
(^for every time the “plot” button is pressed)
I am super lost right now. Thank you in advance for your help.