I have struggle with create a prompts for this can someone please help.

์กฐํšŒ ์ˆ˜: 1 (์ตœ๊ทผ 30์ผ)
Hong
Hong 2024๋…„ 2์›” 9์ผ
๋Œ“๊ธ€: Image Analyst 2024๋…„ 2์›” 10์ผ
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
Hong
Hong 2024๋…„ 2์›” 9์ผ
Hi since the it just said sin20 in the textbook so i assume it should be radiant that's why i just put sin(20)
Image Analyst
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
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!
  ๋Œ“๊ธ€ ์ˆ˜: 1
Hong
Hong 2024๋…„ 2์›” 9์ผ
Hi,
Thanks for helping but i also have the problem on try to put the formula into matlab bc i keep getting the message that it can comput

๋Œ“๊ธ€์„ ๋‹ฌ๋ ค๋ฉด ๋กœ๊ทธ์ธํ•˜์‹ญ์‹œ์˜ค.

์นดํ…Œ๊ณ ๋ฆฌ

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!

Translated by