登录论坛

查看完整版本 : [求助]问个有关取最小值的问题~


dale516
2008-05-23, 13:28
呃...问个很弱智的问题~
比如:已知X10,X11,X12,X20,X21,X22,X30,X31,X32九个变量的经过计算得到的具体数值,
然后有行矩阵A,矩阵中的元素是由以上9个变量中的任意3个取最小值,进行排列组合出的1x27的行矩阵。
问题,matlab里有没有指令,可以直接比较三个变量的最小值并输出...我拿C里的循环嵌套,3个一组比较的...实在很崩溃~:ft:
:lovely: 希望达人指点,表嘲笑我啊~我是需要时才现学的菜鸟...先谢谢了!~

Just For Matlab
2008-05-23, 20:37
matlab里面有个求最小值的函数min,具体用户可以查看帮助
在命令窗口输入help min就会列出一系列关于min的用法,不过全是英文
好好钻研吧
help min
MIN Smallest component.
For vectors, MIN(X) is the smallest element in X. For matrices,
MIN(X) is a row vector containing the minimum element from each
column. For N-D arrays, MIN(X) operates along the first
non-singleton dimension.

[Y,I] = MIN(X) returns the indices of the minimum values in vector I.
If the values along the first non-singleton dimension contain more
than one minimal element, the index of the first one is returned.

MIN(X,Y) returns an array the same size as X and Y with the
smallest elements taken from X or Y. Either one can be a scalar.

[Y,I] = MIN(X,[],DIM) operates along the dimension DIM.

When complex, the magnitude MIN(ABS(X)) is used, and the angle
ANGLE(X) is ignored. NaN's are ignored when computing the minimum.

Example: If X = [2 8 4 then min(X,[],1) is [2 3 4],
7 3 9]

min(X,[],2) is [2 and min(X,5) is [2 5 4
3], 5 3 5].