[英]how to find min and max of float number in matlab
MATLAB中的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試圖從數組min
獲取索引[2.1,3.4,5.6,7.6]
。 要解決此問題,只需將變量命名為其他變量即可。
編輯:並且,如果您正在函數外部運行它,請清除min
和max
,如@Acorbe所指出的。
您需要清除min
和max
因為它們已經被分配,並且它們的變量對應變量隱藏了函數名。
要將它們用作功能,請先執行
clear min
clear max
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.