Question: Create a MATLAB function script file to calculate the coordinates ( x , y ) of the peak points in the range of x values

Create a MATLAB function script file to calculate the coordinates
(x, y) of the peak points in the range of x values for the function y = x^21.
Define the function with the following (function definition line):
function [yp, xp]= Peak(xStart, xEnd)
where xStart is the starting value of x in the range to find the peak points,
and xEnd is the ending value of x in the range to find the peak points.
yp is the y-coordinate of the peak at the end of the signal, and
xp is the x-coordinate of the peak at the end of the signal.
Test by calling the Peak function in the Command Window with xStart =-4 and xEnd =4:
[yp, xp]= Peak(-4,4);
The expected result is yp =-1 and xp =0.
Suggestions:
- Use the command maxPeak = findpeaks(y) to find the maximum peak points of the signal.
- Use the command minPeak =-findpeaks(-y) to find the minimum peak points of the signal.
- Use the command xp = double.empty(1,0) to initialize the output xp as an empty row vector.
- Use the command yp = double.empty(1,0) to initialize the output yp as an empty row vector.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!