Page 1 of 7 E7 Spring 2009 Midterm I SID: UNIVERSITY OF CALIFORNIA, BERKELEY Department of Civil and Environmental Engineering. Practice Midterm 01

Similar documents
E77 Midterm Examination I Monday September 26, 2005

Put your initials on the top of every page, in case the pages become separated.

Introduction to MATLAB LAB 1

12 whereas if I terminate the expression with a semicolon, the printed output is suppressed.

Matlab notes Matlab is a matrix-based, high-performance language for technical computing It integrates computation, visualisation and programming usin

E7 Midterm Exam 1. #11: TuTh 8-10 #12: TuTh #13: TuTh 12-2 #14: TuTh 2-4 #15: TuTh 4-6 #16: MW 8-10 #17: MW #18: MW 2-4 #19: MW 4-6

Creates a 1 X 1 matrix (scalar) with a value of 1 in the column 1, row 1 position and prints the matrix aaa in the command window.

UNIVERSITY OF CALIFORNIA COLLEGE OF ENGINEERING

Mysterious or unsupported answers will not receive full credit. Your work should be mathematically correct and carefully and legibly written.

UNIVERSITI TEKNIKAL MALAYSIA MELAKA FAKULTI KEJURUTERAAN ELEKTRONIK DAN KEJURUTERAAN KOMPUTER

Introduction to Programming for Engineers Spring Midterm Examination. February 23, Questions, 45 Minutes

EGR 111 Introduction to MATLAB

Exam 3 SCORE. MA 114 Exam 3 Spring Section and/or TA:

Statement of integrity: I did not, and will not, violate the rules of academic integrity on this exam.

Introduction to Matlab. By: Hossein Hamooni Fall 2014

Chapter 2. MATLAB Fundamentals

PowerPoints organized by Dr. Michael R. Gustafson II, Duke University

MATLAB BASICS. < Any system: Enter quit at Matlab prompt < PC/Windows: Close command window < To interrupt execution: Enter Ctrl-c.

Mechanical Engineering Department Second Year (2015)

QUICK INTRODUCTION TO MATLAB PART I

Introduction to MATLAB

Laboratory 1 Octave Tutorial

MATLAB Fundamentals. Berlin Chen Department of Computer Science & Information Engineering National Taiwan Normal University

WINTER 2017 ECE 102 ENGINEERING COMPUTATION STANDARD HOMEWORK #3 ECE DEPARTMENT PORTLAND STATE UNIVERSITY

ECE 202 LAB 3 ADVANCED MATLAB

MATH 2221A Mathematics Laboratory II

1. Register an account on: using your Oxford address

Matlab Tutorial. The value assigned to a variable can be checked by simply typing in the variable name:

OUTLINES. Variable names in MATLAB. Matrices, Vectors and Scalar. Entering a vector Colon operator ( : ) Mathematical operations on vectors.

Math 355: Linear Algebra: Midterm 1 Colin Carroll June 25, 2011

MATLAB Programming for Numerical Computation Dr. Niket Kaisare Department Of Chemical Engineering Indian Institute of Technology, Madras

Teaching Manual Math 2131

MATLAB TUTORIAL WORKSHEET

An Introduction to Numerical Methods

An Introduction to MATLAB

CIS 110 Introduction to Computer Programming Summer 2016 Midterm. Recitation # (e.g., 201):

An Introduction to MATLAB II

Introduction to MATLAB

Appendix A. Introduction to MATLAB. A.1 What Is MATLAB?

Variable Definition and Statement Suppression You can create your own variables, and assign them values using = >> a = a = 3.

Matlab Tutorial and Exercises for COMP61021

A very brief Matlab introduction

AMS 27L LAB #2 Winter 2009

Introduction to MATLAB

1) As a logical statement, is 1 considered true or false in MATLAB? Explain your answer.

Page 1 of 11 Name/SID: SOLUTIONS UNIVERSITY OF CALIFORNIA COLLEGE OF ENGINEERING

University of Engineering and Technology, Taxila Department of Civil Engineering

Matlab Tutorial 1: Working with variables, arrays, and plotting

Getting Started. Chapter 1. How to Get Matlab. 1.1 Before We Begin Matlab to Accompany Lay s Linear Algebra Text

Math 7 Elementary Linear Algebra PLOTS and ROTATIONS

MATH 261 EXAM I PRACTICE PROBLEMS

ECON 502 INTRODUCTION TO MATLAB Nov 9, 2007 TA: Murat Koyuncu

EE 301 Signals & Systems I MATLAB Tutorial with Questions

Part I. There are 5 problems in Part I, each worth 5 points. No partial credit will be given, so be careful. Circle the correct answer.

Chapter 1 Introduction to MATLAB

Finding, Starting and Using Matlab

Name: Dr. Fritz Wilhelm Lab 1, Presentation of lab reports Page # 1 of 7 5/17/2012 Physics 120 Section: ####

Computing Fundamentals Plotting

MATLAB Project: Getting Started with MATLAB

INTRODUCTION TO MATLAB PLOTTING WITH MATLAB

Introduction to Matlab

Math 213 Exam 2. Each question is followed by a space to write your answer. Please write your answer neatly in the space provided.

Table of Contents. Introduction.*.. 7. Part /: Getting Started With MATLAB 5. Chapter 1: Introducing MATLAB and Its Many Uses 7

Stokes Modelling Workshop

Matlab Tutorial for COMP24111 (includes exercise 1)

AP PHYSICS B 2009 SCORING GUIDELINES

ENGR 1181 Autumn 2015 Final Exam Study Guide and Practice Problems

MATLAB Tutorial. Digital Signal Processing. Course Details. Topics. MATLAB Environment. Introduction. Digital Signal Processing (DSP)

Plotting - Practice session

Models for Nurses: Quadratic Model ( ) Linear Model Dx ( ) x Models for Doctors:

0 Graphical Analysis Use of Excel

Introduction to Matlab

CSE/NEUBEH 528 Homework 0: Introduction to Matlab

Experiment 1: Introduction to MATLAB I. Introduction. 1.1 Objectives and Expectations: 1.2 What is MATLAB?

How to learn MATLAB? Some predefined variables

PC-MATLAB PRIMER. This is intended as a guided tour through PCMATLAB. Type as you go and watch what happens.

Getting Started with MATLAB

MATLAB Lesson I. Chiara Lelli. October 2, Politecnico di Milano

Math 52 Final Exam March 16, 2009

EGR 111 Functions and Relational Operators

Chemistry 30 Tips for Creating Graphs using Microsoft Excel

ROSE-HULMAN INSTITUTE OF TECHNOLOGY

Introduction to Matlab to Accompany Linear Algebra. Douglas Hundley Department of Mathematics and Statistics Whitman College

A Brief Introduction to MATLAB

Programming in Mathematics. Mili I. Shah

Introduction to Matlab

MATLAB Basics EE107: COMMUNICATION SYSTEMS HUSSAIN ELKOTBY

Math 52 - Fall Final Exam PART 1

EE3TP4: Signals and Systems Lab 1: Introduction to Matlab Tim Davidson Ext Objective. Report. Introduction to Matlab

Select the Points You ll Use. Tech Assignment: Find a Quadratic Function for College Costs

Lab1: Use of Word and Excel

Computational Modelling 102 (Scientific Programming) Tutorials

Laboratory 1 Introduction to MATLAB for Signals and Systems

CS 184, Fall 1996 Midterm #1 Professor: unknown

Matrix Transformations The position of the corners of this triangle are described by the vectors: 0 1 ] 0 1 ] Transformation:

Nuts & Bolts guide to MATLAB

Math 308 Autumn 2016 MIDTERM /18/2016

STAT 391 Handout 1 Making Plots with Matlab Mar 26, 2006

Activity: page 1/10 Introduction to Excel. Getting Started

ALGEBRA 2 W/ TRIGONOMETRY MIDTERM REVIEW

Transcription:

Page 1 of E Spring Midterm I SID: UNIVERSITY OF CALIFORNIA, BERKELEY Practice Midterm 1 minutes pts Question Points Grade 1 4 3 6 4 16 6 1 Total Notes (a) Write your name and your SID on the top right corner of EVERY page (including the first page) (b) Full credit will be awarded only if the correct answer is given in the box provided. Partial credit may be awarded with respect to the work you show outside the boxes (c) You may not leave the exam room before the exam s (d) No calculator / computer is allowed (e) You may have one sheet of notes written on both sides Your PRINTED FULL NAME + signature Please circle your LAB Section: 11 M-W 6-8 1 M-W 1-1 13 M-W -4 14 M-W 4-6 1 Tu-Th 8-1 16 Tu-Th 1-1 1 Tu-Th 1-18 Tu-Th -4 1 Tu-Th 4-6 M-W 8-1 1 M-W 1-1 Wheeler Tu-Th 6-8 3 Tu-Th 6-8 Wheeler 4 M-W 6-8 Wheeler 1

Page of 8 E Spring Midterm 1 SID: Question 1 Consider the following equation: F = G m m r Where G is a constant equal to 6.63x1-11, and m1, m, and r are all arrays of size n by 1. Circle the answer to the following questions about writing this equation in MatLab. (a) What is the correct way to calculate the array F? A) F = G*m1*m/r^ B) F = G*m1.*m/r*r C) F = G*m1.*m./r^ D) F = G*m1.*m./r.^ E) F = G*(m1.*m)./r.*r (b) Now assume that F is calculated in the command window. What is true about the dimensions (size) of F? A) F will be a column vector B) F will be a row array C) F will be a scalar value D) F will be a square matrix E) Not enough information to tell 1 (c) Assuming that G, m1, m, and r are scalar numbers, then class of F is: A) char B) string C) double D) struct E) cell (d) If G, m1, m, and r are now only scalar numbers, then the following code will correctly calculate the value of F: >> F = G*m1*m/r^ UNIVERSITY OF CALIFORNIA, BERKELEY Engineering Spring 8

Page 3 of 8 E Spring Midterm 1 SID: Question For the following multiple choice or / Questions, please clearly circle or underline your answer to each question. If you are uncertain or unable to circle only 1 answer, please justify yourself in words beneath the question in a blank space. (a) A function s workspace shares the same workspace as the command window (b) Which of the following statements on mfiles and MatLab functions are true? I. mfiles have no input or output variables II. functions must have input or output variables III. functions can be called within another function, whereas mfiles cannot IV. mfiles use the command window s workspace a) I only b) II and III c) I, II, IV d) I, IV e) IV only (c) Given an m x n array of numbers, it is possible to access any set of sub-matrices, horizontal, or vertical arrays using a single line of matlab. (d) Given a random real number X, the absolute value of the difference between floor(x) and ceil(x) must be 1 (e) It is possible for a function to call itself within the body of its code UNIVERSITY OF CALIFORNIA, BERKELEY Engineering Spring 8

Page 4 of 8 E Spring Midterm 1 SID: Question 3 The following MATLAB commands are saved in a script file called examquestion3a.m and examquestion3b.m What is the value of x when the script file examquestion3a.m is executed? What is the value of n and counter when examquestion3b.m is executed? Do not worry about the exact format of the output. Script file examquestion3a.m x = ; for i = 1:1 for j = 1: if i == j x = x + 1; x = 1 Script file examquestion3b.m n = 6; counter = 1; while n ~= 1 if rem(counter,) == n = n/; else n = n/4; counter = counter + 1 n = 1 counter = 6 UNIVERSITY OF CALIFORNIA, BERKELEY Engineering Spring 8

Page of 8 E Spring Midterm 1 SID: Question 4 Consider the following lines of MatLab code entered in the MATLAB command window: >> X = [ ]; >> Y = 6:; >> W = 3; >> Z = ; >> V = 8; What is the output when the following commands are typed in sequence from the MATLAB command window? Do not worry about the exact format of the output. >> V ~= X ans = 1 1 1 1 >> V == Y ans = 1 >> X+Y/ ans = 1. 1. 11. 11. >> V/Z*W ans = 1 >> 4*W/Z^+ ans = >> Z*[1::6] ans = 6 1 >> a = [W,Z,V,Z] >> [a,x ] UNIVERSITY OF CALIFORNIA, BERKELEY Engineering Spring 8

Page 6 of 8 E Spring Midterm 1 SID: ans = 3 8 >> (X>=Y) ~= (W* == Y) ans = 1 UNIVERSITY OF CALIFORNIA, BERKELEY Engineering Spring 8

Page of 8 E Spring Midterm 1 SID: Question 1. Consider the following parametric functions: x = sin( t) e y = cos( t) e cos( t) cos( t) cos(4t) sin cos(4t) sin t 1 t 1 Create a function in MatLab called mybutterfly which accepts an array of numbers (t) as input. The corresponding array of X and Y coordinates should be the output, as described by the equations above. The declaration line of the function should look like: function [X,Y] = mybutterfly(t) Write the remainder of the mybutterfly.m here: function [X,Y] = mybutterfly(t) X = sin(t)*.(exp(cos(t)) *cos(4*t) sin(/1).^); Y = cos(t)*.(exp(cos(t)) *cos(4*t) sin(/1).^); Plot your function for t = to 1π with an increment of.1π. No additional plotting parameters are needed (e.g. axis, grid, line style, plot color). This plot should go in the bottom right corner of a [ x ] subplot. You may use up to 3 lines of code. >> [X,Y] = mybutterfly(t); >> subplot(,,4), plot(x,y) >> UNIVERSITY OF CALIFORNIA, BERKELEY Engineering Spring 8

Page 8 of 8 E Spring Midterm 1 SID: UNIVERSITY OF CALIFORNIA, BERKELEY Engineering Spring 8 Question 6 Consider the following arrays defined in MatLab s workspace: = 1 8 6 4 3 1 W = 6 Z Retrieve the following sub-matrices from W and Z in a single line of MATLAB code: Retrieve or create from W the following sub-arrays: >> W([,4],[1,3]) [ ] >> W([,:1,13:1]) [ ] 1 1 >> W([1,]) Retrieve or create from Z the following sub-arrays: [ ] 6 >> Z(6:1) 6 >> [Z(,3:-1:1);Z(1,:)] Retrieve or create from W and Z the following sub-arrays: 4 6 3 >> [Z(:,1:), W(:3,:3)]