Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask MATLAB Expert

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.

MATLAB, Engineering

  • Category:- MATLAB
  • Reference No.:- M91780236

Have any Question?


Related Questions in MATLAB

Question a safe prime is a prime number that can be written

Question : A safe prime is a prime number that can be written in the form 2p + 1 where p is also a prime number. Write a MATLAB script file that finds and displays all safe primes between 1 and 1000.

Assignmentq1 find the laplace transforms of the following

Assignment Q.1 Find the Laplace transforms of the following functions: (a) t 2 + at + b and (b) sin(2nΠt/T) Q.2 Find f (t) for the following F(s) = α[ f (t)]. (i) 5/(s + 3), (ii) 1/s 2 + 25, (iii) 1/s(s+1) Q.3 Find the L ...

Assignment matlab programmingusing appropriate matlab

Assignment: MatLab Programming Using appropriate MatLab syntax, write the code required to analyse and display the data as per the problem description. The order of the MatLab Program should be as follows: Variables and ...

Suppose that a student has the option of enrolling for a

Suppose that a student has the option of enrolling for a single elective during a term. The student must select a course from a limited list of options: "English, " "History, " "Biology, " "Computer, " or "Math." Constru ...

Prepare a 3 - 10 pages long reportprepare a presentation

Prepare a 3 - 10 pages long report Prepare a presentation with 5 - 9 slides. The slides will include introduction (need and similar work), theoretical background (tested neural networks), Data, Results (Comparison of the ...

Assignment - matlab programmingusing appropriate matlab

Assignment - MatLab Programming Using appropriate MatLab syntax, write the code required to analyse and display the data as per the problem description. The order of the MatLab Program should be as follows: Variables and ...

Assignment -data is given on which want to do computational

Assignment - Data is given on which want to do computational production planning using Metaheuristic MATLAB Programming: 1) Ant Colony Algorithm on both Partial and Total Flexible Problem. 2) Bee Algorithm on both Partia ...

Lab assignment - matlab matrix relationallogical operators

Lab Assignment - MATLAB Matrix, Relational/Logical Operators and Plotting This laboratory exercise/assignment will involve you 1) practicing multiplication operators in MATLAB; 2) practicing relational and logical operat ...

Question 1 manipulate spectral imagehyperspectral images

Question 1. Manipulate spectral image Hyperspectral images can be seen as a generalisation of normal colour images such as RGB images. In a normal RGB colour image, there are 3 channels, i.e. channels for red colour, gre ...

Discrete optimisation- solve the following two problems

Discrete Optimisation - Solve the following two problems with both exhaustive enumeration and branch and bound - Problem 1 is a mixed integer linear optimisation problem (the problem has both discrete and continuous vari ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As