- #1

- 590

- 0

as an excercise we had to make a program that will give me the highest value in a given matrix

what i tried doing was:

a=rand(5)

n=1

max=a(n)

while a(n)<max

n=n+1;

max=a(n);

end

what i thought this would do was take a random 5x5 matrix, start from a(1,1) and find the largest value,,, not so,

how can i make such a program using "while", not "if", what i want it to do is take a loop and keep on adding 1 to the previous n, keeping the largest value as max