findpeaks matlab
时间: 2023-09-09 08:11:05 浏览: 51
`findpeaks` is a MATLAB function that is used to find local maxima in a vector or a matrix. It returns the indices and values of the peaks found.
Here's an example usage of `findpeaks`:
```matlab
% Create a sample vector
x = [1 2 3 2 1 4 3 2 1];
% Find the peaks in the vector
[peaks, peakIndices] = findpeaks(x);
% Display the results
disp("Peaks: " + num2str(peaks));
disp("Peak Indices: " + num2str(peakIndices));
```
In this example, `findpeaks` will identify the local maxima in the `x` vector, which are the numbers 3 and 4. The output `peaks` will be `[3 4]`, and `peakIndices` will be `[3 6]`, corresponding to the indices of the peaks.
Note that `findpeaks` has additional options and can be used with different arguments to customize its behavior. You can refer to the MATLAB documentation for more details on how to use this function.