Question: 1 . Open HW 6 Ex 2 Data.txt file and take a look at it . The first variable ( on each line ) is

1. Open HW6Ex2Data.txt file and take a look at it. The first variable (on each line) is time and the second one is height.
Sketch a flowchart and write a live script which does the following tasks:
It loads HW6Ex2Data.txt file (hint: search help for readmatrix function).
Your script must then plot height versus time (as a blue solid line). Note: time is the horizontal axis.
Our goal for this question is marking the peaks of this plot. Here is what you need to do:
After opening and plotting data, your script calls a function that you write named peakFinder to find the indices (locations) of the peaks of the height array. Write the peakFinder function which receives one array (height) as its input and gives one array (indices of the peaks) as its output. Please note that a peak is a value which is larger than its preceding and following values. So, your function needs to check this comparison (each sample of the height is checked with its previous and next samples) and find the indices of all the peaks and send them out as an array to your script.
Once your main script receives this array it must plot the peaks (as red asterisks markers) on top of your previous plot (you need to use hold on function).
If you have calculated the indices correctly and plotted them properly, your asterisks must have matched the peaks of your first plot.
Use appropriate labels and legends for your plots.
Save your live script as HW6Ex2FirstnameLastname.mlx
Optional: If your function has recognized 3 peaks, you may use a more restricted constraint to find a peak (e.g., using the previous two samples and next two samples, instead of just the previous and next samples).

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 Programming Questions!