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

1 Ansicht (letzte 30 Tage)
Collin Kerr
Collin Kerr am 24 Apr. 2016
Kommentiert: Collin Kerr am 5 Mai 2016
%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.)

Akzeptierte Antwort

Image Analyst
Image Analyst am 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 Kommentare
Image Analyst
Image Analyst am 24 Apr. 2016
Since there are multiple solutions for any given distance, I'd probably create an image, say 1000 by 1000 where you use linspace(8,15,1000) to create the velocities and linspace(angle1, angle2, 1000). Then use meshgrid or have a double for loop over all possibilities. Then use contour() to show which velocity, angle pairs will give the required distance.
velocities = linspace(8, 15, 1000);
angles = linspace(10, 80, 1000);
[V, A] = meshgrid(velocities, angles);
distanceImage = some function of V and A.
imshow(distanceImage, []);
hold on;
contour(........
You can finish it. Please give it a try.
Collin Kerr
Collin Kerr am 5 Mai 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.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Graphics 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!

Translated by