I have struggle with create a prompts for this can someone please help.
์กฐํ ์: 1 (์ต๊ทผ 30์ผ)
์ด์ ๋๊ธ ํ์
The maximum horizontal distance, d, traveled by a projectile fired is calculated using the following formula ๐ = ๐ฃ ^2 /2๐ *( 1 + โ1 + 2๐ ๐ฆ0 /๐ฃ 2 sin2 ๐ )๐ ๐๐2๐
Where โข d is the total horizontal distance travelled by the projectile.
v is the velocity at which the projectile is launched
g is the gravitational acceleration: 9.81 ๐/๐ 2
ฮธ is the angle at which the projectile is launched
๐ฆ0 is the initial height of the projectile
Write a MATLAB program that prompts the user to input values for ๐ฃ and ๐ฆ0, and computes and outputs the distance ๐ for ๐ = 10ยฐ, 15ยฐ, 20ยฐ, โฆ , 40ยฐ. Note that when ๐ฆ0 = 0, the formula becomes ๐ = ๐ฃ 2 ๐ ๐ ๐๐2๐. Use this fact to test your implementation for the general case.
๋๊ธ ์: 9
Image Analyst
2024๋
2์ 10์ผ
@Hong ๐ ๐๐2๐ means "sine of two times theta (the angle)", not "sine of 20 radians" or "sin(20)".
๋ต๋ณ (1๊ฐ)
Vaibhav
2024๋
2์ 9์ผ
ํธ์ง: Vaibhav
2024๋
2์ 9์ผ
Hi Hong
I understand that you are facing issues in creating prompts to get input from the user.
You can consider using the "input" function to receive input from the user via MATLAB's command window. You can refer to the code snippet below:
% MATLAB program to compute projectile distance for various angles
% Clear variables and console
clear;
clc;
% Constants
g = 9.81; % Gravitational acceleration (m/s^2)
% Prompt user for input values
v = input('Enter the launch velocity v (m/s): ');
y0 = input('Enter the initial height y0 (m): ');
% Display the header for the output
fprintf('Angle (ยฐ)\tDistance (m)\n');
fprintf('-------------------------\n');
% Calculate and output the distance for angles 10ยฐ to 40ยฐ
for theta_deg = 10:5:40
% Convert angle from degrees to radians for computation
% Calculate the distance
% Output the distance for the current angle
end
You can refer to the MathWorks documentation below to learn more about "input" function:
Hope this helps!
์ฐธ๊ณ ํญ๋ชฉ
์นดํ ๊ณ ๋ฆฌ
Help Center ๋ฐ File Exchange์์ Matrix Indexing์ ๋ํด ์์ธํ ์์๋ณด๊ธฐ
์ ํ
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!