i cannot find the minimum values for matrix.

4 ビュー (過去 30 日間)
ARIFF HAIKAL
ARIFF HAIKAL 2019 年 11 月 19 日
コメント済み: ARIFF HAIKAL 2019 年 11 月 19 日
theres no problem to find maximum values. but when it come to find minimum values, got error as below.
can somebody tell me what is the error mean ? and how exactly to find the minimum values in each colum in matrix T ?
Thank you,
T =
1.0000 242.0000 24.7385 33.8409 1.0000
2.0000 716.0000 83.2151 50.1744 1.0000
>> M = max (T)
M =
2.0000 716.0000 83.2151 50.1744 1.0000
>> N = min (T)
Array indices must be positive integers or logical values.
  1 件のコメント
Erivelton Gualter
Erivelton Gualter 2019 年 11 月 19 日
編集済み: Erivelton Gualter 2019 年 11 月 19 日
I could not reproduce this error. The following works fine to me.
T =[1.0000, 242.0000, 24.7385, 33.8409, 1.0000; ...
2.0000, 716.0000, 83.2151, 50.1744, 1.0000]
M = max (T)
N = min (T)

サインインしてコメントする。

採用された回答

Erivelton Gualter
Erivelton Gualter 2019 年 11 月 19 日
Alternative method to find the minium value for each column:
min(T,[],1)
  4 件のコメント
Daniel M
Daniel M 2019 年 11 月 19 日
This answer shouldn't have worked. You must have inadvertently solved the issue of overloading the min function.
Otherwise, to get the min of just some columns, only pass in those columns:
T = [1.0000 242.0000 24.7385 33.8409 1.0000; 2.0000 716.0000 83.2151 50.1744 1.0000];
cols = [1 3 5]; % pick these columns
N = min(T(:,cols));
ARIFF HAIKAL
ARIFF HAIKAL 2019 年 11 月 19 日
hi brothers,
yup it got 1 overwritten variable 'min'. so i put 'clear min' .
and it succeed. this one also " N = min(T(:,cols)); " can be used.
Thank you. :)

サインインしてコメントする。

その他の回答 (1 件)

Daniel M
Daniel M 2019 年 11 月 19 日
You must have overwritten 'min' as a variable, and doing min(T) is trying to index into a variable at non-integer positions. That, or you've overloaded the function min with another. To check for this, what is the output of
which min -all
Also, copy and paste the following code exactly, and tell me if it works
clear all
T = [1.0000 242.0000 24.7385 33.8409 1.0000; 2.0000 716.0000 83.2151 50.1744 1.0000];
min(T)

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by