Create a script that creates a random vector

Assignment Help MATLAB Programming
Reference no: EM131055833

Part 1. Basic Scripts

Problem I. Write a simple script that will calculate the volume of a hollow sphere. The volume can be calculated by using the following formula;

v=4Π/3 (ro3 - ri3)

Where r, is the inner radius and ro is the outer radius. Assign a value to a variable for the inner radius, and also assign a value to another variable for the outer radius. Then, using these variables, assign the volume to a third variable. Your script should accept user input. Print your results using an fprintf statement.

Problem 2. Create a function called "hollowSphere" that calculates the volume using the formula shown in Problem I. Then write a script that prompts the user for the value of the inner radius and outer radius, your script will then call the function that you created to calculate the hollow sphere area. Print your results using an fprintf statement from your script.

Part 2. Plotting

Problem 1. Create a script that creates a random vector with 50 integer values in the range 1 - 20 and assigns the result to r,. Creates a random vector with 50 integer values in the range 30 - 50 and assigns the result to ro. Create a scatterplot of volume vs r,, and a second scanerplot of volume vs ro. Add labels to your x and y axis. Add titles to the plots. The first plot should have red circles, and the second plot should have blue squares as the markers. Lastly, create a third plot that plots volume vs ri and ro, add a legend to this plot. Make sure you are using your "hollowSphere" function. Also, you will need to modify the function operators to be element wise operators as shown below;

volume = ( (4*pi) /3)* (ro3 - ri3) ;

Part III. If Structures

Problem 1. The script that was developed in Part I did not considered checking for errors. In this specific problem, we want to allow the user to enter any value of the inner and outer radius as long as the value of the inner radius is smaller than that of the outer radius. Therefore, we must modify the script in Part I Problem 2 to check for this condition. If the user enters a value of ro that is smaller than r, we want to display a message that tells the user that the values are invalid and that we will swap the them. Swap the values of ni and n and allow your script to calculate and print the results. (Hint: when swapping the values, you are assigning the original value of r.) tor, and vice versa. You will find it necessary to use a third value that stores a temporary value). Make sure you are using your "hollowSphere" function.

Problem 2. Now consider the situation in which the user enters a negative value for either ri or ro, clearly this is wrong and should be avoided. Therefore, if the user enters a negative value for either of the variables, the script will display a message stating that the input values are invalid but we will convert them to positive. If either of the input values are negative, make them positive. Then check for the conditions in the previous problem (i.e. ra should be greater than ri) and continue with the calculations as usual. Make sure you are using your "hollowSphere" function.

Expectations: All scripts should have your name and comments about the different parts of the script. Your work should be original and be your own. No teamwork is allowed in this Exam. Each problem is solved using a separate script file, with the exception of any function that you created, as functions can be called by any script and do not require duplication.

You must submit your an files and zip them in an archive before submitting.

Reference no: EM131055833

Questions Cloud

What is the firm cost of retained earnings : The firm has net income of $2 million, Sales of $15 million, total assets of $14 million, common equity of $9 million, and common dividend of $1 million, and 1 million shares outstanding with a total market value of $23 million. What is the firm's co..
Confidence interval for the true proportion of high school : Dylan wants to determine a 99 percent confidence interval for the true proportion of high school students in the area who attend their home basketball games. How large of a sample must he have to get a margin of error less than 0.04? [To find n, u..
What is the standard deviation of the revised portfolio : Research reported in the chapter shows that the correlation between the U.S. and Japanese stock markets is 0.35. Assume that the standard deviations of the two markets are 15 percent and 18 percent, respectively. What is the variance of the revised p..
Describe what working capital practices : Describe what working capital practices, including methods of capital budgeting analysis techniques. Analyze the potential pitfalls in capital budgeting practices that a business should be aware of. Develop a simple statement of cash flows for the bu..
Create a script that creates a random vector : Create a function called "hollowSphere" that calculates the volume using the formula shown in Problem I. Then write a script that prompts the user for the value of the inner radius and outer radius, your script will then call the function that you..
Annual interest tax shield and debt issuance : In recent years, Haverhill Corporation has averaged a net income of $10 million per year on net sales of $100 million per year. It currently has no long-term debt, but is considering a debt issue of $5million. The interest rate on the debt would be 6..
Confidence the proportion of all americans : In a random sample of 750 Americans, 39.1% indicated that they have a cat for a pet. Estimate with 93% confidence the proportion of all Americans that have cats as pets. (Give the confidence interval in percentages.)
The public needs to know - revised version : Your boss has asked you (a communication specialist) to write an informative paper about the free clinic that will be opening in your local neighborhood for those without medical insurance. Describe the process and benefits of the program for the..
What is the YTM of the bond : Norma has one share of stock and one bond. The total value of the two securities is 1,466.4 dollars. The stock pays annual dividends. The next dividend is expected to be 5.37 dollars and paid in one year. In two years, the dividend is expected to be ..

Reviews

Write a Review

MATLAB Programming Questions & Answers

  Write a matlab script m-file to play a guessing game the

write a matlab script m-file to play a guessing game. the user will try to guess a number between 1 and 100. your

  Write a matlab program segment

Plot the given function in MATLAB for x ranging from -1 to 1. Put a proper title of the plot, also label the axes appropriately.

  Matlab program which will determine your vehicle fuel usage

Create a MATLAB program which will determine your vehicle fuel usage (MPG, miles/gallon) rating for a user defined number of trips ('for' repetition structure).

  Symmetry in the rod

matlab programming

  Write a matlab script called estimate_e

How does your actual accuracy compare to the relative tolerance you chose - Can you provide the answer as soon as possible and use basic MATLAB concepts to make this program?

  Determine the range of k for stability

Determine the range of K for stability. Develop an m-file to calculate the closed-loop poles for K from 0 to 5 with an increment of 0.1 (you may want to use the for loop in MATLAB). What are the poles when K = 4?

  Write program to compute output of mixcolumns transformation

Using Matlab write a program to compute the output of the MixColumns transformation for the following sequence of input bytes "67 89 AB CD" Apply the InvMixColumns transformation to the obtained result to verify your calculation.

  Define the future-value-of-money formula

The future-value-of-money formula relates how much a current investment will be worth in the future, assuming a constant interest rate.

  Find the errors in the matlab codes

The program runs, then stops and gives an error of double going into the switch. I changed the code to make it output the sounds, but my whole reasoning was to make this version work with the row vectors.

  The gauss-newton method

Write up your results using our standard format. Show and discuss the results of Steps 1-3 in some detail, including the observed convergence rates of steepest descent versus the Gauss-Newton method

  Apply svm and baysain for classification

Took the output of segmentation as input and then apply svm and baysain for classification. I want exect(in 3*3 matrix) output as that results from svm and Bayesian both side. Took the fs4 in the code as input do apply the svm and bayesian algo..

  Explain the difference in trajectory

Write a single function that outputs the total time of flight, range of the projectile and the velocity on impact given inputs of g, the angle,

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd