I don't know how to take the next step.

3 views (last 30 days)
%8 to 15 meters is the range %Velocity is 0,15,30,45,60,75,90
clc,clear
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))/(a); %The 1/2 and times 2 cross out for the denom
disp(Q1)
%%Horizontal Range
H = V_o*cosd(Theta)*(Q1); fprintf('The Horizontal Range of the launch is %0.3f \n', H)
%% Vertical Height
V = (b^2)/(a*2)*2; fprintf('The Vertical Height of the launch is %0.3f \n', V)
%% Only input variable F to figure out the velocities and launch angles. T = menu ('Select the targeted distance','8','9','10','11','12','13','14','15');
if T == 8
Im trying to use the menu fuction to finish of my program, what information I need to find, which I have been unable for the past couple of days is, the formula. The menu function shall be the input to the second half of this program, Ive been stuck at this one part for days. (The input to this part of the program should be only the target distance. The output from this part of the program should be the velocities and launch angles for the projectile.)

Accepted Answer

Image Analyst
Image Analyst on 24 Apr 2016
menu() returns the button number, not the button text like questdlg() does, so if they click the "8" button, it will return 1 and 9 will return 2, etc.. So you need to do this:
buttonNumber = menu ('Select the targeted distance','8','9','10','11','12','13','14','15');
T = buttonNumber + 7;
  6 Comments
Collin Kerr
Collin Kerr on 5 May 2016
Ill be blunt, I have never seen any of those ways of coding before, due to this being my first year as an engineering student. I looked up how to use each one of those codes, but I went ahead and went a different route cause I did not understand your way. I was wondering if you could go ahead and finish the way you wanted me to? I already turned in the project, but im curious what your coding would have done. And what the finished product would have looked like. Thanks.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by