八度/Matlab:两个向量中的最小值 [英] Octave/Matlab: min of two vectors

查看:412
本文介绍了八度/Matlab:两个向量中的最小值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

让我们取两个向量:

a = [1 ; 2; 3]
b = [0 ; 9 ; -5]

如果我想要向量的最小值和它的位置,我可以简单地做到:

If I want minimum value of the vector and it's position I can simply:

[x, ix] = min(a)

我还可以比较两个向量并获得最小值:

I can also compare two vectors and get minimum values:

> min(a, b)
ans =

   0
   2
  -5

但是不可能获得两个向量的最小值的位置:

But it is impossible to get positions of min values of two vectors:

> [x, ix] = min(a, b)
x =

   0
   2
  -5

error: element number 2 undefined in return list

为什么?如何获得它们?有没有简单的方法?

Why? How to get them? Is there a simple method?

推荐答案

操作方法如下:

[v id]=min([a,b]')

这篇关于八度/Matlab:两个向量中的最小值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆