%------------------------------------------------------------------- % Problem 3: scalars, arrays, operators % Fill in the blanks with the output that MATLAB will generate % for the following input. %------------------------------------------------------------------- a=1-1-1-1 % a = % % ____________________ b = [1;2;3]' % b = % % _______________________ c = 1 + sqrt(-2) % c = % % _______________________ d = [1 2 3;3,4,5] d(:,3) = d(:,1) d(:,[3 4])=d(:,[2 3]) % d = % % _______________________ %------------------------------------------------------------------- % Problem 4: Conditionals % Fill in the blanks with the output that MATLAB will generate % for the following input. %------------------------------------------------------------------- a = ~( (1>0) | ~(1>0) ) % a = % % _______________________ b = [1 2;3 4]==2 % b = % % _______________________ c = ~~3 % c = % % _______________________ d = -~3 % d = % % _______________________ e = ~-3 % e = % % _______________________ f = sin(pi)==0 % f = % % _______________________ a = 0; b = 0; c = 2; g = ~(a <= b & b < c & a < c) % g = % % _______________________ h = (a == 0 & b ~= c & a ~= ~c) % h = % % _______________________ %------------------------------------------------------------------- % Problem 5: Conditionals, nested conditions % Write a program that asks the user for a name with 3 letters. Your % program should store the name in a variable called $name$. The % program should output whether the name that the user typed in is: % in upper case (e.g. TOM), or % in lower case (e.g. tom), or % in title case (e.g. Tom), or % in messy case, which is non of the above (e.g. ToM, TOm, tOm, ...). % Some help on how to deal with strings: % Imagine you have a string assigned to a variable, e.g. % var='Jen' % There is a Matlab function called $double$ that converts a string % into an array of numbers where each number represents the position % of the according letter in the table of ASCII values. Here is a small % portion of the table of ASCII values: % % letter position letter position % A 65 a 97 % B 66 b 98 % C 67 c 99 % D 68 d 100 % E 69 e 101 % F 70 f 102 % ... ... % ... ... % U 85 u % V 86 v 118 % W 87 w 119 % X 88 x 120 % Y 89 y 121 % Z 90 z 122 % If you typed name=double('Jen') in the Command Window then an array % containing 3 numbers: 74 101 110 would be stored in w. % For simplicity, you can assume that any letter that is not uppercase % (position 65 through 90) is lower case. %-------------------------------------------------------------------