Quiz7_Solution - You may not use any built-in MATLAB...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Quiz 7: For Loops 2 Name: ASE 201 Assume that your workspace has an array, A. You have no prior knowledge of the dimensions nor the values in A. Using FOR loops, write the code that will calculate three values: 1. The maximum value in the array 2. The minimum value in the array 3. The average of all the values in the array
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: You may not use any built-in MATLAB functions except to nd the dimensions of A. Solution: %quiz7.m [n,m] = size(A); min = A(1,1); max = A(1,1); ave = 0; for j = 1:n for k = 1:m ave = ave + A(j,k); if A(j,k) > max max = A(j,k); elseif A(j,k) < min min = A(j,k); end end end ave = ave / (n*m);...
View Full Document

This note was uploaded on 02/14/2010 for the course ASE 201 taught by Professor Hayes during the Spring '07 term at University of Texas at Austin.

Ask a homework question - tutors are online