






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!







A) The two lines below are entered at the command prompt:
x = [ 9 3 0 6 3] y = mod((sqrt(length(((x+5).[1 2 3 4 5]))5)),3)
What is the value of y?
a) 0 b) 3 c) 2 d) 5
B) Consider the following vector in Matlab:
vec = [1 0 0 0 0];
Which of the following will produce an error?
a) vec(6) = 1; b) vec(4) = [ ]; c) vec(0) = 1; d) vec([4 5]) = 1; e) vec = [[6 [5] vec]];
B(
where B did not exist beforehand.
What is true about range1 and range2?
A) They must be the same or you get an error B) range2 must be greater than range1 or you get an error C) range1 must be greater than range2 or you get an error D) They do not have to be same and B will be filled with zeros where assignments were not explicitly made.
Write a function called stat that takes in a vector of positive and negative numbers and returns four statistics about the data:
You must use iteration to get any credit
stDev = sqrt((sum(data.^2)/length(data)) – mean)
Write a function called sumCells that consumes a Cell Array containing vectors of varying lengths and a number, N. It returns the sum of all the vectors in the cell array of length N.
Example: sumCells( { [3 5 2], [ 2 5], [1 2], [ ], 42 } , 2 ) returns sum([2 5]) + sum([1 2]) = 10
a = 1 : (1/100) : 2;
x = 1: for ind = x x = 1 end
a) x = 1:5, ind = 1: b) x = 1:5, ind = 5 c) x = 1, ind = 5 d) x = 1, ind = 1:
I) A(2)=[] A(5)=[] A(6)=[]
II) A([2 5 6]) = 0
III) A(6)=[] A(5)=[] A(2)=[]
IV) A(A<0)=[]
a) II only b) all of the above c) III and IV d) I and IV
a) an Error b) True d) False d) Cannot be determined.
Write a script that will remove from a cell array, A , all the cells containing data of length 1. Append every cell removed from A to the end of a second cell array, B. Hint: strings respond to the length(…) function with the number of characters in the string.
For example, given the following cell array
A = { 1:10, 2:20, ‘c’, 1 , 2 , [ 6, 7 ] , 'cs1371' } B = { ‘original data’ } The final arrays should look like this:
A = { 1:10, 2:20, [6, 7], ‘cs1371’ } B = {‘original data’, ‘c’, 1, 2}