I am trying to find the max peak of the graph (image below) without using 'findpeaks' syntax. Please help me out. The .mat file is attached.

조회 수: 2 (최근 30일)
I am using the following code to plot the graph:
clc
a=importdata('robin roy.mat');
b=a.data;
x=b(22000:25830,1);
x(x<0)=[];
plot(x);

채택된 답변

Greg Dionne
Greg Dionne 2017년 3월 17일
[maxval, maxindex] = max(x)
  댓글 수: 5
Biswarup  Dutta
Biswarup Dutta 2017년 3월 18일
Hi Greg, Thanks for your help. Now, I get that. But one more thing, the max value I get is 1.22. How can I get the value of the point on X-axis, where the peak exists?
Image Analyst
Image Analyst 2017년 3월 18일
What does that mean? You get BOTH the height of the curve (x=1.22), and the index where it occurs. What more do you want?
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 25;
storedStructure = importdata('robin roy.mat');
b = storedStructure.data;
x = b(22000:25830,1);
x(x<0) = [];
plot(x, 'b-', 'LineWidth', 2);
grid on;
xlabel('Index', 'FontSize', fontSize);
ylabel('x', 'FontSize', fontSize);
[maxXValue, indexOfMaxXValue] = max(x)
% Draw lines to the peak
line([indexOfMaxXValue, indexOfMaxXValue], [0, maxXValue],...
'LineWidth', 2, 'Color', 'r');
line([1, indexOfMaxXValue], [maxXValue, maxXValue],...
'LineWidth', 2, 'Color', 'r');
message = sprintf('The max value of %f\noccurs at an index of %d.',...
maxXValue, indexOfMaxXValue);
uiwait(helpdlg(message));

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Image Analyst
Image Analyst 2017년 3월 17일
Try the attached.

카테고리

Help CenterFile Exchange에서 Descriptive Statistics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by