E7+Sp2010+Assignment+1+Solutions

# E7+Sp2010+Assignment+1+Solutions - Joe Student 12345678...

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

Joe Student Assignment 1 12345678 February 5, 2010 1 Assignment 1: Functions, Vectors, and Matrices Problem 1: Matlab Workspace and Function Types (28) 1.1) The last command would return 11. +1 The mathematical equation a = a+1 does not have a solution. +1 The ‘=’ symbol represents the assignment operator. +1 1.2) a) The value of tan( π /2) is infinity (or undefined). +1 b) EDU>> tan(pi/2) ans = 1.6331e+16 EDU>> isa (ans,'double') ans = 1 The answer returned is a double. +1 if this answer and the Matlab code containing the “isa” command are present. c) The correct answer is ii) Double Double +1 d) The value of 1/0 is infinity (or undefined) in mathematics. +1 EDU>> 1/0 ans = Inf EDU>> isa (ans,'double') +1 for having this command ans = 1 The answer returned is a double. +1 e) The correct answer is iii) DoubleXDouble Float +1 f) The domain D is all positive reals. +1 The largest domain within (- π /2, π /2) for the function tan(x) such that the range is D is: (0, π /2). +1 The largest domain of f such that the range is all the real numbers is: (0, π /2). +1

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

View Full Document
Joe Student Assignment 1 12345678 February 5, 2010 2 1.3) Matlab returned an error because it cannot have a variable with the name 1b. +1 1.4) This session of Matlab would return an error. +1 The function clear removes all variables from the workspace. +1 The correct edit is to change the 2 nd line to something that doesn’t clear the value of x. Example code: EDU>> x = 1 x = 1 EDU>> y = 2 y = 2 EDU>> x x = 1 +1 if example code OR written explanation is provided. Any answer that changes the 2 nd line of code so that it doesn’t change x is acceptable. 1.5) The error message happened after the first command because we entered sin(x) when x did not have an assigned value. +1 We did not get an error message after the 3 rd command because the 2 nd command assigned the value of 1 to x. +1 The fifth command will return an error. +1 1.6) EDU>> clear EDU>> x='aa' x = aa EDU>> y='bb' y = bb EDU>> strcmp(x,y) ans = 0 Matlab output not required for this question The last command returned the value 0. +1
Assignment 1 12345678 February 5, 2010 3 EDU>> x='aa' x = aa EDU>> y='aa' y = aa EDU>> strcmp(x,y) ans = 1 Matlab output not required for this question The last command returned the value 1. +1 A valid type of strcmp is iv) CharXChar Logical. +1 1.7) EDU>> isa(1,'logical') ans = 0 EDU>> isa(1,'double') ans = 1 EDU>> y=logical(1) +1 for either logical (1) or true (1). This is the only graded command. y = 1 EDU>> isa(y,'logical') ans = 1 A valid type of isa is iv) Int8XChar Logical. +1 1.8) EDU>> and(1,0) ans = 0 EDU>> and(1,1) ans = 1 EDU>> isa(and(1,1),'logical') +1. This command must match exactly. ans =

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 02/19/2010 for the course ENGINEERIN 72826 taught by Professor Sengupta/leachman/johnson during the Spring '10 term at Berkeley.

### Page1 / 15

E7+Sp2010+Assignment+1+Solutions - Joe Student 12345678...

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

View Full Document
Ask a homework question - tutors are online