How to fit a line through all tops of a graph?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Christian Klinkenberg
am 20 Sep. 2018
Beantwortet: Zenin Easa Panthakkalakath
am 25 Sep. 2018
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
0 Kommentare
Antworten (1)
Zenin Easa Panthakkalakath
am 25 Sep. 2018
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]);
0 Kommentare
Siehe auch
Kategorien
Mehr zu Annotations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!