资源简介
本程序使用matlab求取二维数组的极大值与极小值
代码片段和文件信息
function varargout = localMaximum(xminDist exculdeEqualPoints)
% function varargout = localMaximum(xminDist exculdeEqualPoints)
%
% This function returns the indexes\subscripts of local maximum in the data x.
% x can be a vector or a matrix of any dimension
%
% minDist is the minimum distance between two peaks (local maxima)
% minDist should be a vector in which each argument corresponds to it‘s
% relevant dimension OR a number which is the minimum distance for all
% dimensions
%
% exculdeEqualPoints - is a boolean definning either to recognize points with the same value as peaks or not
% x = [1 2 3 4 4 4 4 4 4 3 3 3 2 1];
% will the program return all the ‘4‘ as peaks or not - defined by the ‘exculdeEqualPoints‘
% localMaximum(x3)
% ans =
% 4 5 6 7 8 9 11 12
%
% localMaximum(x3true)
% ans =
% 4 7 12
%
%
% Example:
% a = randn(1003010);
% minDist = [10 3 5];
% peaks = localMaximum(aminDist);
%
% To recieve the subscript instead of the index use:
% [xIn yIn zIn] = localMaximum(aminDist);
%
% To find local minimum call the function with minus the variable:
% valleys = localMaximum(-aminDist);
if nargin < 3
exculdeEqualPoints = false;
if nargin < 2
- 上一篇:MATLAB非线性优化fmincon详解
- 下一篇:MATLAB计算对极线程序
评论
共有 条评论