source: MML/trunk/applications/doc_html/applications/common/maxn.html @ 4

Last change on this file since 4 was 4, checked in by zhangj, 10 years ago

Initial import--MML version from SOLEIL@2013

File size: 4.4 KB
Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
2                "http://www.w3.org/TR/REC-html40/loose.dtd">
3<html>
4<head>
5  <title>Description of maxn</title>
6  <meta name="keywords" content="maxn">
7  <meta name="description" content="MAXN N-D Array Maximum.">
8  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
9  <meta name="generator" content="m2html &copy; 2003 Guillaume Flandin">
10  <meta name="robots" content="index, follow">
11  <link type="text/css" rel="stylesheet" href="../../m2html.css">
12</head>
13<body>
14<a name="_top"></a>
15<div><a href="../../index.html">Home</a> &gt;  <a href="#">applications</a> &gt; <a href="index.html">common</a> &gt; maxn.m</div>
16
17<!--<table width="100%"><tr><td align="left"><a href="../../index.html"><img alt="<" border="0" src="../../left.png">&nbsp;Master index</a></td>
18<td align="right"><a href="index.html">Index for applications/common&nbsp;<img alt=">" border="0" src="../../right.png"></a></td></tr></table>-->
19
20<h1>maxn
21</h1>
22
23<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
24<div class="box"><strong>MAXN N-D Array Maximum.</strong></div>
25
26<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
27<div class="box"><strong>function [mx,idx,col]=maxn(A) </strong></div>
28
29<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
30<div class="fragment"><pre class="comment">MAXN N-D Array Maximum.
31 MAXN(A) returns the maximum value found in the array A.
32
33 [MX,Row,Col] = MINN(A) for 2-D A returns the maximum value MX as well as
34 the row and column subscripts where the maximum appears. Row and Col are
35 column vectors if multiple maximums appear in A.
36
37 [MX,Idx] = MAXN(A) returns the maximum value MX as well as the linear
38 indices Idx of all elements in A that are equal to MX.
39 To get the row, column, ..., subscripts associated with the linear indices
40 use IND2SUB(size(A),Idx).</pre></div>
41
42<!-- crossreference -->
43<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
44This function calls:
45<ul style="list-style-image:url(../../matlabicon.gif)">
46</ul>
47This function is called by:
48<ul style="list-style-image:url(../../matlabicon.gif)">
49</ul>
50<!-- crossreference -->
51
52
53<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
54<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function [mx,idx,col]=maxn(A)</a>
550002 <span class="comment">%MAXN N-D Array Maximum.</span>
560003 <span class="comment">% MAXN(A) returns the maximum value found in the array A.</span>
570004 <span class="comment">%</span>
580005 <span class="comment">% [MX,Row,Col] = MINN(A) for 2-D A returns the maximum value MX as well as</span>
590006 <span class="comment">% the row and column subscripts where the maximum appears. Row and Col are</span>
600007 <span class="comment">% column vectors if multiple maximums appear in A.</span>
610008 <span class="comment">%</span>
620009 <span class="comment">% [MX,Idx] = MAXN(A) returns the maximum value MX as well as the linear</span>
630010 <span class="comment">% indices Idx of all elements in A that are equal to MX.</span>
640011 <span class="comment">% To get the row, column, ..., subscripts associated with the linear indices</span>
650012 <span class="comment">% use IND2SUB(size(A),Idx).</span>
660013
670014 <span class="comment">% 2004-04-06</span>
680015 <span class="comment">% D.C. Hanselman, University of Maine, Orono, ME  04469-5708</span>
690016
700017 <span class="keyword">if</span> ~isnumeric(A)
710018    error(<span class="string">'Numeric Input Expected.'</span>)
720019 <span class="keyword">end</span>
730020 mx=max(A(:));
740021
750022 <span class="keyword">if</span> nargout==2                   <span class="comment">% [MX,idx]=MAXN(A)</span>
760023    idx=find(A==mx);
770024   
780025 <span class="keyword">elseif</span> nargout==3 &amp; ndims(A)==2 <span class="comment">% [MX,Row,Col]=MAXN(A)</span>
790026    [idx,col]=ind2sub(size(A),find(A==mx));
800027   
810028 <span class="keyword">elseif</span> nargout==3
820029    error(<span class="string">'Three Output Arguments Requires 2-D Input.'</span>)
830030 <span class="keyword">end</span></pre></div>
84<hr><address>Generated on Mon 21-May-2007 15:32:41 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> &copy; 2003</address>
85</body>
86</html>
Note: See TracBrowser for help on using the repository browser.