Question

Matlab Code: You will have to read in firing inputs from a user (angle and power)....

Matlab Code:

You will have to read in firing inputs from a user (angle and power). Prior to doing this, you should report out to the user via the command window the current wind speed and direction. For the value of wind speed, you can use a random number with magnitude range from -25 to 25 mph where -25 is wind blowing toward the left and +25 is wind blowing to the right. Note you can generate a random number between -25 to +25 by first multiplying rand by 50 then subtracting 25 from the result. To assign direction, you might want to just alternate left and right each turn. You will also want to read in power and angle from the user where angle is the firing angle from 0 to 90 degrees:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Wind Speed (mph, plus to right, minus to left): -10

Enter Firing Angle (0 to 90 deg from horizontal: 30

Enter Firing Power (0 to 100): 30

Enter Cannon Ball Mass (kg): 5

0 0
Add a comment Improve this question Transcribed image text
Answer #1

MATLAB CODE

% clearing any past varibles and screen clc clear %report out to the user via the command window the current wind speed and d

CODE TEXT

% clearing any past varibles and screen

clc

clear

%report out to the user via the command window the current wind speed and direction

%range is allowed from -25 to 25 mph

%-ve is for left and +ive for right

%For this (as hinted in question) we use random value generation

%Generate number between [0 , 50] then subtract 25 to get the value in the desired range of [-25, 25]

%Another way is to generate random number between [0 ,25] for magnitude and

%alternate between the sign for left and right (also mentioned in the

%question ( IN this we will use first method)

%randi function generates number between specified by first parameter

%second parameter tells to generate 1 number

wind_speed = randi ([0 , 50], 1);

%subtract 25 to get in range

wind_speed = wind_speed - 25;

%report to the user

X = sprintf('Wind Speed (mph, plus to right, minus to left): %d', wind_speed);

disp(X)

%Ask user Firing Angle

firing_angle = input('Enter Firing Angle (0 to 90 deg from horizontal):');

%Ask user Firing Power

firing_power = input ('Enter Firing Power (0 to 100):');

%Ask user Cannon Ball Mass

cannonball_mass = input ('Enter Cannon Ball Mass (kg): ');

OUTPUT

Wind Speed (mph, plus to right, minus to left): -10 Enter Firing Angle (0 to 90 deg from horizontal: 30 Enter Firing Power (0

Please comment for any further assistance

Add a comment
Know the answer?
Add Answer to:
Matlab Code: You will have to read in firing inputs from a user (angle and power)....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • MATLAB You Cannot Use guide, You must create a GUI using code only Problem 1 (100...

    MATLAB You Cannot Use guide, You must create a GUI using code only Problem 1 (100 pts) This week you will repeat the second problem from Week 8 (the problem is restated below for your convenience) but you will add a GUI (without using guide) for the user to control the execution of the program. Your program should do the following: Create a figure that contains a plotting area and user interface controls Allow the user to input the initial...

  • I can't figure out how to change my code to write info in from a text...

    I can't figure out how to change my code to write info in from a text file for the input. I'll post the context of the problem I am working on and the code I have finished so far. The program will create a Catapult object that will create a searchable matrix of trajectories for the given speeds and angles. The object should store these values in a 2D array. Given a target range of minimum and maximum distances, representing...

  • solve using the code provided Write a program that will continuously read words from the user,...

    solve using the code provided Write a program that will continuously read words from the user, word by word till the user enter "quit”, the program should print each word in reverse order. Sample Session: (User input in Red color) Enter a word: hello olleh Enter a word: Ahmad damhA Enter a word: quit Good Bye 9 dinclude <iostream> 10 dinclude <cstring> 11 using namespace std; 12 13 int main() { 14 15 char word(100); 16 cin>>word; 17 while (strcmp(word,...

  • This is the code we have to edit, i know how to do everything except finding...

    This is the code we have to edit, i know how to do everything except finding if the x and y are in the space, please explain to me when you do the code. We are using addshape() api and more. public class Skeleton { public static void main(String[] args) { //================================ //== Setting up game window ====== SpaceGame myGame; //declaring the object form the class Scanner scan = new Scanner(System.in); System.out.println("What is the window name? "); //window title text...

  • Before you start doing this code Read carefully there is a format that you have to...

    Before you start doing this code Read carefully there is a format that you have to follow HERE IS THE FORMAT YOU MUST USE FOR HW #2 - NOTE THE IF ELSE IF...not IF IF IF HW #2 Format : Instructions: This program will generate some information for a user about interplanetary travel (pretend we can travel easily to other planets for this problem). This program will perform calculations concerning weight on various planets as well as travel time between...

  • The histogram below shows the responses of the 706 people from last semester to the Survey question: "What is the fa...

    The histogram below shows the responses of the 706 people from last semester to the Survey question: "What is the fastest you've ever driven? The average is about 90 mph and the SD is 15 mph. The green lines indicate one SD above and below average and the blue lines indicate 2 SDs above and below average. You can't use the graph above to answer the questions below, but you can use it to make sure your answers are in...

  • read instructions carefully please matlab only Write a MATLAB function for a BMI calculator that receives the inputs for body weight (lbs)and height (ft) from the user's program, calculates th...

    read instructions carefully please matlab only Write a MATLAB function for a BMI calculator that receives the inputs for body weight (lbs)and height (ft) from the user's program, calculates the BMI using the equation below, displays the BMI category, and outputs the BMI value tothe user's program W (kg) h2 (m2) BMI Display Normal if 18.5 s BMI 25 Display Overweight if 25 s BMI <30 Display Obese if BMI 2 30 Else display underweight So you will create two...

  • You are participating in a summer internship with the Coast Guard. You have been assigned the...

    You are participating in a summer internship with the Coast Guard. You have been assigned the duty of determining the direction in which a Coast Guard speedboat should travel to intercept unidentified vessels. One day, the radar operator detects an unidentified vessel at a distance of 35.0 km from the radar installation in the direction 15.0° east of north. The vessel is traveling at 29.0 km/h on a course at 40.0° east of north. The Coast Guard wishes to send...

  • Create a program (Lab9_Act1_Write.py) that will read in data from the keyboard and store it in...

    Create a program (Lab9_Act1_Write.py) that will read in data from the keyboard and store it in a file. Your program should prompt the user for the name of the file to use and then request values be entered until the user is done. This data should be written to two files: a text file, user_file_name.txt and a comma separated value file, user_file_name.csv. To help you with decision making, we suggest that you ask the user to input data representing students’...

  • Your friend is about to drive away after moving out and you notice that they left...

    Your friend is about to drive away after moving out and you notice that they left behind their basketball, so you decide to throw it at a 45 degree from the horizontal towards the truck. If the truck is 7.3 m away from you, at what speed must you throw the ball for it to make it into the truck? Assume you launch the ball at the same height as the truck bed. Report the value in m/s rounded to...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT