PracticeQuestions1

# PracticeQuestions1 - E7 Introduction to Computer...

This preview shows pages 1–3. Sign up to view the full content.

E7: Introduction to Computer Programming Spring Semester 2008: Midterm-I Practice Questions for Scientists and Engineers Following questions are collected from different sources and are not arranged in any particular order. You are encouraged to work on as many questions as possible for reasonable amount of practice. 1. Which of the following are software ? Which are hardware ? Explain your answer . (i) Interpreter, (ii) CPU, (iii) MATLAB, (iv) Internet, (v) e-mail, (vi) MATLAB Toolbox, (vii) Modem, (viii) Web Browser, (ix) CD-ROM, (x) Bits and bytes. 2. Circle the VALID MATLAB variable names in the following list. Explain the reasons for invalid variable names. readsibm+pc NEPTUNE disp sin a2z 123 log cosine t velocity for_you 4_youfor AccelerationDueToGravity Cal_Berkeley Stanford University time his_and_hers her’s_only pi average acceleration_due_to_gravity_on_the_moon 3. Trigonometric functions in MATLAB use arguments in radians or degrees as desired by the user. (TRUE or FALSE?) (Check MATLAB help!) 4. Given the arrays A=[6 4 ; 3 7] and c=[2 5] , which ONE of the following MATLAB command works correctly? (a) A \ c (b ) A .\ c (c) A \ c' (d) A \ C' 5. What is the result of the following two MATLAB statements >> M=[2 4; 6 1; 3 5]; >> min(max(M')) University of California, Berkeley Page - 1 of 7

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
E7: Introduction to Computer Programming Spring Semester 2008: Midterm-I Practice Questions for Scientists and Engineers 6. If the following MATLAB statements are run sequentially in the Command Window which one of them will generate errors upon execution. Why? >>clear >>A=[2 4 6 ; 5 5 6] >>H=[2 3; 4; 4] >>Q{2,4}='yes' >>a=5, b=8, a^b; >>A .+ 3 >>A + 3 >> H=[2 3; 4, 4] >>help matlab >>A * H >>'yes'+'no' >>['yes','no'] >>A=[3 4; 2 3; 5 6], A(:,3) >>x=sqrt(x) >>plot([1:10],logspace(1:3)) >>function test; >>5+input('age?'); 7. Given the function function y=fun(x); y=x^2; x=5; What value does y hold after following script is executed? >>y=3; x=2; x=fun(y); >>y=x*y 8. Let A=[2 4 6 ; 5 5 6] . What values will be displayed after the following MATLAB commands are executed? >>A(:,2)=[]; A(1,:)=[]; A
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 03/04/2009 for the course E 7 taught by Professor Patzek during the Spring '08 term at Berkeley.

### Page1 / 7

PracticeQuestions1 - E7 Introduction to Computer...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online