clc;
close all;
clear;
workspace;
format long g;
format compact;
fontSize = 20;
s = load('data.mat')
data = s.data;
hFig = figure;
plot(data, 'b-', 'LineWidth', 2)
grid on;
xlabel('Index', 'FontSize', fontSize);
ylabel('Signal', 'FontSize', fontSize);
hFig.WindowState = 'maximized';
[maxValue, indexOfMax] = max(data)
[minValue, indexOfMin] = min(data)
tempSignal = data;
tempSignal(indexOfMax:end) = inf;
indexLeft = find(tempSignal < 0, 1, 'last')
hold on;
plot(indexLeft, data(indexLeft), 'r.', 'MarkerSize', 40);
tempSignal = data;
tempSignal(1 : indexOfMax) = inf;
indexMiddle = find(tempSignal < 0, 1, 'first')
hold on;
plot(indexMiddle, data(indexMiddle), 'r.', 'MarkerSize', 40);
tempSignal = data;
tempSignal(1 : indexOfMin) = -inf;
indexRight = find(tempSignal > 0, 1, 'first')
hold on;
plot(indexRight, data(indexRight), 'r.', 'MarkerSize', 40);
Best Answer