The error occurs because findpeaks
expects additional inputs (parameters) to be specified as name-value pairs, and you might have accidentally passed a numeric input that caused confusion.
If you want both the peak values (y
locations) and their corresponding x
locations, you need to pass the x
values explicitly as the first argument to findpeaks
. Here's the correct way to do it:
[pks, locs] = findpeaks(Temperature, Scope);
Temperature
: Your y
values (the data you want to find peaks for).Scope
: Your x
values (the corresponding x-axis data for the peaks).The output will be:
pks
: The peak values in the Temperature
array.locs
: The corresponding x
values from the Scope
array where the peaks occur.
Scope = 1:0.1:10; % Example x-axis values Temperature = sin(Scope) + 0.1*rand(size(Scope)); % Example y-axis values with noise [pks, locs] = findpeaks(Temperature, Scope); % Plot results plot(Scope, Temperature); hold on; plot(locs, pks, 'ro'); % Mark peaks xlabel('Scope'); ylabel('Temperature'); title('Peaks in Temperature Data');
Scope
and Temperature
have the same length.findpeaks
with both y
and x
inputs to get the correct x
locations for the peaks.
[pks, locs] = findpeaks(Temperature, Scope, 'MinPeakHeight', 0.5, 'MinPeakDistance', 10);
Let me know if you need further clarification!
Matlabsolutions.com provides guaranteed satisfaction with a
commitment to complete the work within time. Combined with our meticulous work ethics and extensive domain
experience, We are the ideal partner for all your homework/assignment needs. We pledge to provide 24*7 support
to dissolve all your academic doubts. We are composed of 300+ esteemed Matlab and other experts who have been
empanelled after extensive research and quality check.
Matlabsolutions.com provides undivided attention to each Matlab
assignment order with a methodical approach to solution. Our network span is not restricted to US, UK and Australia rather extends to countries like Singapore, Canada and UAE. Our Matlab assignment help services
include Image Processing Assignments, Electrical Engineering Assignments, Matlab homework help, Matlab Research Paper help, Matlab Simulink help. Get your work
done at the best price in industry.