How to plot this?

%Invert the data to use findpeaks to find the valleys
negdepthFeet = -depthFeet;
dur = duration(15,0,0);
% Use findpeaks
[lowerLowWater,lowerLowUTC] = findpeaks(negdepthFeet,
tideTime,'MinPeakProminence',10/12,'MinPeakDistance',dur);
lowerLowWater = -lowerLowWater;
MLLWmud = mean(lowerLowWater);
MLLW = 0;
% Tide level in feet relative to MLLW
feetMLLW = (depthFeet-MLLWmud);

Answers (1)

I am not certain what you want to plot, since you did not specify that.
Try this:
tideTime = linspace(0, 4*pi); % Create Data
depthFeet = cos(5*tideTime).*sin(tideTime); % Create Data
negdepthFeet = -depthFeet;
[lowerLowWater,lowerLowUTCidx] = findpeaks(negdepthFeet);
lowerLowWater = -lowerLowWater;
MLLWmud = mean(lowerLowWater);
MLLW = 0;
figure
plot(tideTime, depthFeet)
hold on
plot(tideTime(lowerLowUTCidx), depthFeet(lowerLowUTCidx), 'vr')
hold off
grid
Experiment to get different results.

Tags

Asked:

on 3 Dec 2019

Answered:

on 3 Dec 2019

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!