I don't know how to take the next step.
2 次查看(过去 30 天)
显示 更早的评论
%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.)
0 个评论
采纳的回答
Image Analyst
2016-4-24
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 个评论
Image Analyst
2016-4-24
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.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Encryption / Cryptography 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!