This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: end end end 4. The following 3 files are named exam10.m, f1.m, and f2.m. All are stored in the same directory. What is printed when exam10 is executed? %This file is named exam10.m for a = 0.4 fprintf( '%d', f1(a, a+1)); end % This file is named f1.m function f1out = f1(x,y) if x+y <= 3 f1out = f2( x+y ); else f1out = f2( x ) + f2( y ); end % This file is named f2.m function f2out = f2(z) if ( z <= 2 ) f2out = z; else f2out = z*(z-1); end 2 5. What is printed by the following MATLAB code? for x = 0:3 a( x+1 ) = 1.1*(x^2); end for y = 0:3 b( y+2 ) = a( mod(y+1, 4) + 1) + ceil( a(y+1) ); end for i = 1:length(b) fprintf( '%.2f ', b(i) ); end 3...
View Full Document
This note was uploaded on 08/06/2010 for the course ENGR 3 taught by Professor Ben-yaakov during the Summer '08 term at UCSB.
- Summer '08