** How-To's **

** numbers **

Try to re-write the expression somehow.

A safe way to find roots of a quadratic: x

e.g. ax

M = input('enter M: ') N = input('enter N: ') A = 10*rand(M,N); %----using array ops: on A(:), else they apply on each column arraySum = sum( A(:) ); fprintf(' arraySum= %f \n', arraySum ) [arrayMin, iarrayMin] = min( A(:) ) fprintf(' arrayMin= %f at i: %d \n', arrayMin, iarrayMin ) [arrayMax, iarrayMax] = max( A(:) ) fprintf(' arrayMax= %f at i: %d \n', arrayMax, iarrayMax ) %----using loops: Sum = 0 ; Min = Inf ; Max = -Inf ; for i = 1:M % for each row i for j = 1:N % for each col j aij = A(i,j); %save to avoid multiple lookups Sum = Sum + aij; if( aij <= Min ) Min = aij; iMin = i; jMin = j; end %if if( aij >= Max ) Max = aij; iMax = i; jMax = j; end %if end %j end %i fprintf(' Sum= %f \n', Sum) fprintf(' Min= %f at i,j: %d %d \n', Min, iMin, jMin ) fprintf(' Max= %f at i,j: %d %d \n', Max, iMax, jMax )