Whats wrong with my quadratic formula?
Show older comments
V_o = input('Velocity at launch = ');
Theta = input('Elevation angle at launch = ');
a=9.81; %Its a given
b=V_o*sind(Theta) %It makes the coding a bit less confusing.
c=0; %Also a given
fprintf('The velocity for the launch is %d meters per second. \n', V_o)
fprintf('The elevation angle for the launch is %d degrees. \n', Theta)
Q1=(-b-sqrt(b^2-4*a*c))/2*a;
disp(Q1)
For some reason the code is not lining up with a calculators numbers. I was wondering if someone could explain what specifically is wrong with the quadratic formula and how could I be able to fix it?
Accepted Answer
More Answers (2)
Roger Stafford
on 19 Apr 2016
Apparently you are trying to see how many seconds the object in question would take to return to earth. The velocity equation is:
v = -a*t+b
If you integrate with respect to t, you get
x = int(v,t) = -a*t^2/2+b*t
The solution is either t = 0 (the beginning) or t = b/(2*a) (at the end.) Your mistake was twofold. You had a positive value for a, and you didn't include the 1/2.
Fantahun
on 13 Nov 2024
0 votes
% Define Q1=(-b-sqrt(b^2-4*a*c))/(2*a);
Categories
Find more on MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!