Assignment-8-EENG 1910- Completed

docx

School

University of North Texas *

*We aren’t endorsed by this school

Course

1910

Subject

Electrical Engineering

Date

Dec 6, 2023

Type

docx

Pages

8

Uploaded by queenicicle00

Report
EENG 1910: Project I – Introduction to Electrical Engineering Assignment-8 1. Create a MATLAB function that will take as inputs the radius ( r ) and height ( h ) of a cone and calculate its volume. The formula to compute the volume of a cone is as follows. V = 1 3 π r 2 h Write a descriptive comment on the use of the function so that the user by typing help nameofyourfunction has all the necessary information to use your function. Question 1 In each of the following questions ( 2. & 3. ), first, evaluate the given MATLAB code for each of the test cases without using MATLAB. Then, using MATLAB, check the answers you obtained first.
2. if n > 1 a. n = -25 m = -35 m = n+1 b. n = 2 m = 3 elseif n==0 c. n = 10 m = 11 m = n d. n = 0 m = 0 else m = n-10 end Question 2 3. switch letter a. letter = ‘p’ = Error case ‘x’ b. letter = ‘y’ = Yes disp(‘Hello’) c. letter = ‘q’ = Error case{‘y’, ‘Y’} d. letter = ‘Q’ = Quit disp(‘Yes’) e. letter = ‘x’ = Hello case ‘Q’ disp(‘Quit’) otherwise disp(‘Error’) end
Question 3 Note : When you copy and paste codes into MATLAB, some characters may not correctly translate. As a result, you may have to correct them for the script to run properly. 4. A switch statement can often be used in place of a nested ifelse or an if statement with many elseif clauses. Switch statements are used when an expression is tested to see whether it is equal to one of several possible values. The script pickPizzaCase.m posted on Canvas is written using a case statement. Analyze it and convert it to if-elseif-else statement.
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Question 4 5. Write MATLAB script that will prompt the user for a temperature in degrees Celsius, and then a letter ‘F’ for Fahrenheit or ‘K’ for Kelvin. The script should work weather a capital or small case letter is entered. The script will then print the corresponding temperature in the scale specified by the user. For example, the outputs might look as follows. >> conversioncode Please enter a temperature value in Celsius: 45 Do you want K or F? k The temperature in Kelvin is: 318.15. Please enter a temperature value in Celsius: 29.3 Do you want K or F? f The temperature in Fahrenheit is: 84.74. >> conversioncode Please enter a temperature value in Celsius: 78 Do you want K or F? K The temperature in Kelvin is: 351.15. >> conversioncode Please enter a temperature value in Celsius: 74 Do you want K or F? P Please enter F or K!
Note : Lesson-8 has a sample code that could simply be modified. Also, conversioncode is simply the name that I have given to my script. The conversions can be performed using the formulas below. 𝐾 = 𝐶 + 273.15 𝐹 = 𝐶 + 32 Question 5 6. Use a for loop to sum the elements in the following vector: V=[10, 27, -66, 43, 72, 87, 56,98, 33, 23.5, 8.5, 77.7, 36, 24,11, 85, 55, 63, 4, 39, 100, -96, 4, 41, 189, -9,78.3, -83]. You will need to first determine the size ( length ) of the vector. Check your answer using the MATLAB sum function.
Question 6 7. Repeat the previous problem, this time using a while loop. Question 7 8. Create a function called “isInt” to check whether an input number is an integer. The function should display a sentence of the form: “22.5 is not an integer!” or “99 is an integer!” if the inputs were respectively 22.5 and 99.
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Question 8 9. In chemistry, the pH of an aqueous solution is a measure of its acidity. The pH scale ranges from 0 to 14, inclusive. A solution with a pH of 7 is said to be neutral, a solution with a pH greater than 7 is basic, and a solution with a pH less than 7 is acidic. Write a script that will prompt the user for the pH of a solution, and will print whether it is neutral, basic, or acidic. If the user enters an invalid pH, an error message should be printed.
Question 9