Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a user-defined MATLAB function for the following math function: y(x) = 0.6x'e04% +1.5x2e-0.6 The input to the function is x and the output is

image text in transcribed
image text in transcribed
Write a user-defined MATLAB function for the following math function: y(x) = 0.6x'e04% +1.5x2e-0.6 The input to the function is x and the output is y. Write the function such that x can be a vector (use element-by-element operations). (a) Use the function to calculate y(-2) and y(4). (b) Use the function to make a plot of the function y(x) for -45x58. Write a user-defined function that calculates grade point average (GPA) on a scale of 0 to 5, where A = 5, B = 4, C = 3, D = 2, and F = 0. For the function name and arguments, use GPA = GradeptAve (G,C). The input argument G is a vector whose elements are letter grades A, B, C, D, or F entered as a string (e.g., ['ABACFB']). The input argument c is a vector with the corresponding credit hours. The output argument GPA is the calcu- lated GPA rounded to the nearest tenth (i.e., 3.75 is rounded to 3.8, and 3.749 is rounded to 3.7). Use the function to calculate the GPA for a student with the following record: Grade A B F B A D A Credit Hours 4 3 3 2 3 3 3 Write a user-defined function that determines if a number is a prime num- ber. Name the function pr=Trueprime (m), where the input arguments m is a positive integer and the output argument pr is l if mis a prime number and 0 if m is not a prime number. Do not use MATLAB's built-in functions primes and isprime. If a negative number or a number that is not an integer is entered when the function is called, the error message "The input argument must be a positive integer." is displayed. (a) Use the function with 733, 2001, and 107.5. Write a user-defined function that sorts the elements of a vector from the largest to the smallest. For the function name and arguments, use y=downsort (x). The input to the function is a vector x of any length, and the output y is a vector in which the elements of x are arranged in a descending order. Do not use the MATLAB built-in functions sort, max, or min. Test your function on a vector with 14 numbers (integers) randomly distributed between --30 and 30. Use the MATLAB randi function to generate the initial vector

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Administration The Complete Guide To Dba Practices And Procedures

Authors: Craig S. Mullins

2nd Edition

0321822943, 978-0321822949

More Books

Students also viewed these Databases questions

Question

=+you think is being taxed when more money is printed? Why?

Answered: 1 week ago