# i cannot find the minimum values for matrix.

6 views (last 30 days)
ARIFF HAIKAL on 19 Nov 2019
Commented: ARIFF HAIKAL on 19 Nov 2019
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.
Erivelton Gualter on 19 Nov 2019
Edited: Erivelton Gualter on 19 Nov 2019
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 on 19 Nov 2019
Alternative method to find the minium value for each column:
min(T,[],1)
ARIFF HAIKAL on 19 Nov 2019
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. :)

Daniel M on 19 Nov 2019
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)