How to fit a line through all tops of a graph?

2 visualizzazioni (ultimi 30 giorni)
Up to now I have the following MATLAB script:
%% clear; clc; close all for i = (6:21) %go through all measurement files and load data into matrix measurement{i} = dlmread(['Measure',num2str(i),'.txt']); %load measurement data hold on plot(measurement{i}(:,2)) %plot all measurements end
lgd = legend('Measurement 1','Measurement 2','Measurement 3','Measurement 4','Measurement 5','Measurement 6','Measurement 7','Measurement 8','Measurement 9','Measurement 10','Measurement 11','Measurement 12','Measurement 13','Measurement 14','Measurement 15','Measurement 16') lgd.FontSize = 7; xlim([1800 5000]) xlabel('Number of measurement') ylabel('Voltage (V)')
See appendix for an example of such as graph where I want a line through the maxima points

Risposte (1)

Zenin Easa Panthakkalakath
In order to find the local maxima, there is a function by the name 'findpeaks'. Refer to the link below for the documentation:
In order to draw the line, just use the 'plot' function. If the coordinate of the local maximum is (x_max, y_max), then the plot command should be something like this:
plot([0 x_max], [y_max, y_max]);

Categorie

Scopri di più su Line Plots in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by