What is result of x = min(A(:));
9 views (last 30 days)
I am looking at result of a program and value result do not look right Looking at code ( can't run test to check right now)
If (min(e(:) <= 5)
Z = 1
Answer seem to set a=0 There are 26 elements in the array with a value <= 5 So I am wondering is if the results z is 26 or is it equal the lowest value in the array?
Alex Taylor on 6 Feb 2015
The result of
A = [4 5; 8 7];
x = min(A(:))
This is because any matrix in MATLAB can be linearly indexed from 1 to the total number of elements in the matrix. So, the operation A(:) reshapes A into an Nx1 vector, then the min operation scans from the first element to the last element of the N element vector ooking for the minimum.
Scott Webster on 6 Feb 2015
Not sure if part of your confusion is your "order of operations" i.e. the difference between min(e)<5 and min(e<5)... Here is some demo code...
1 2 3 4 5
1 1 1 0 0