{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

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 find 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

{[ snackBarMessage ]}

Ask a homework question - tutors are online