Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
MATLAB 中的minand函数仅适用于整数值。max如何找到双向量的最小值和最大值?
min
max
a = [2.1 3.4 5.6 7.6] min(a)
返回给我:
Subscript indices must either be real positive integers or logicals.
您已min在代码中的某处为数组指定了变量名。
当您调用时min(a),MATLAB 会尝试[2.1,3.4,5.6,7.6]从您的数组中获取索引min。要解决此问题,只需将变量称为其他名称。
min(a)
[2.1,3.4,5.6,7.6]
编辑:如果您在函数之外运行它,请清除minand max,正如@Acorbe 指出的那样。
您需要清除它们min,max因为它们已经被分配并且它们的变量对应物隐藏了函数名称。
要将它们用作函数,请先执行
clear min clear max