how do I solve a quadratic which contains a changing b value
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
The project describes a projectile launched at 34.7m/s/s off a cliff height 89.8404m (dont mind the note) to land at a height of 0 (ground).
I successfully made a piece of code request an angle and supply a distance from the origin where the projectile will land (y=0) .
I then wanted to graph the angle (theta) over distance (x) however I am unable to find the roots from a quadratic that contains a theta that ranges from 1 - 90 degrees. ultimately I'm stuck at around line 27 (b comes out as a nx1 matrix of correct 'b' values from theta =1 -> 90 )
clear,clc
v0=34.7; % initial velocity in m/s. Restricted to a maximum of 125 km/h
prompt = "what is the angle?";
theta = input(prompt);
h = 89.8404; %should be 89.5645?
g = 9.8;
%y = H + v0*t*sin(deg2rad(theta))-0.5*g*(t^2); %full equation, y=0
a = -0.5*g;
b = v0*sin(deg2rad(theta));
c = h;
p = roots([a b c]);
t = p(p>=0);
x = v0*t*cos(deg2rad(theta));
disp(['The distance the rider can travel at a launch angle of ' num2str(theta) ' degrees is: ' num2str(x) ' metres'])
theta_d = (1:1:90)
a = -0.5*g;
b = v0*sin(deg2rad(theta_v));
c = h;
S = roots([a b c])
t = S(S>=0);
1 Commento
Risposte (1)
Davide Masiello
il 31 Mar 2022
Modificato: Davide Masiello
il 31 Mar 2022
Does this help?
clear,clc
v0=34.7; % initial velocity in m/s. Restricted to a maximum of 125 km/h
prompt = "what is the angle?";
theta = 30;%input(prompt);
h = 89.8404; %should be 89.5645?
g = 9.8;
%y = H + v0*t*sin(deg2rad(theta))-0.5*g*(t^2); %full equation, y=0
a = -0.5*g;
b = v0*sin(deg2rad(theta));
c = h;
p = roots([a b c]);
t = p(p>=0);
x = v0*t*cos(deg2rad(theta));
disp(['The distance the rider can travel at a launch angle of ' num2str(theta) ' degrees is: ' num2str(x) ' metres'])
theta_d = (1:1:90);
b = v0*sin(deg2rad(theta_d));
for idx = 1:length(theta_d)
S = roots([a b(idx) c]);
t(idx) = S(S>=0);
end
plot(t,theta_d)
0 Commenti
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!