260 likes | 454 Views
REVIEW 1 EXAM 3. Question 1. Which statement(s) is/are valid to create a string? x = “EGR 115” □ Valid □ Invalid x = ‘EGR 115’ □ Valid □ Invali x = sprintf(‘ %s %d’,class_name,class_num) □ Valid □ Invalid x = str2num(‘115’) □ Valid □ Invalid
E N D
Question 1 • Which statement(s) is/are valid to create a string? • x = “EGR 115” □ Valid □ Invalid • x = ‘EGR 115’ □ Valid □ Invali • x = sprintf(‘ %s %d’,class_name,class_num) □ Valid □ Invalid • x = str2num(‘115’) □ Valid □ Invalid • x=num2str(‘115’) □ Valid □ Invalid • X=double(‘EGR’) □ Valid □ Invalid
Question 2 • This rand statement will give a random number between 6 and 10, the question is which set (from the ones specified below) is correct to represent the possible outcome? • Rand_num= round((rand*4)+6) • {6,7,8,9} • {7,8,9,10} • {7,8,9} • {6,7,8,9,10}
Question 3 • A TYPICAL keyboard is considered to be: • Input device • Output device • Input/output device • None of the above www.wikipedia.com
Question 4 • When using the ‘r+’ access mode, the initial position of the pointer will be: • At the beginning of the file • At the end of the file • At halfway into the file • It will stay where it is (no change from last time the file was open)
Question 5 • Assuming that we are reading a text file that includes only one line and we saved it to a variable named str, look at the screenshot below can you tell which function was used to read such file: • fgetl() • fgets() • fget() • None of the above
Question 6 • Assuming that we are reading a text file that includes only one line and we saved it to a variable named str, look at the screenshot below can you tell which function was used to read such file: • fgetl() • fgets() • fget() • None of the above
Question 7 • The part that is circled is called: function W = M (A,B) • function • Return variables • Function name • Parameters
Question 8 • Consider the code written below, then answer the following questions: • If a file exists with the same name will it be deleted? • If the files doesn’t exist, will it be created?
Question 9 • Consider the code written below, then answer the following questions: • If a file exists with the same name will it be deleted? • If the files doesn’t exist, will it be created?
Question 10 • Consider the code written below, then answer the following questions: • If a file exists with the same name will it be deleted? • If the files doesn’t exist, will it be created?
Question 11 • Which of the following built-in function, will CREATE a plot. • polyval() • polyfit() • Xlabel() • polar()
Question 12 • Consider the following MATLAB code, and decide where is the error: • The error is in the FIRST line. • The error is in the SECOND line. • The error is in the THIRD line. • The error is in the FOURTH line.
Question 13 • The part that is circled is called: function W = M (A,B) • function • Return variables • Function name • Parameters
Question 14 • The part that is circled is called: W = MyFun (A,B) • Function call • Return values • Arguments • Parameters
Question 15 • polyfit() will return the coefficient of the polynomial that best fits the data given. • This statement is TRUE • This statement is FALSE
Question 16 • Consider the following MATLAB code, and decide which type of data you are collecting R = xlsread('myFile.xls'); • numerical • strings • Cell array • Choice a & c are correct.
Question 17 • What value will be in the variable len after executing this MATLAB code: • 10 • 11 • 12 • 13
Question 18 • strcat() is a built-in function that can be used to delete _____________ spaces from a string. • Leading spaces • Intermediate spaces • Trailing spaces • All spaces
Question 19 • After running this MATLAB code, what value will be saved in the variable str_edit • Hello Wo • lo W • lo Wo • loWo
Question 20 • After running this MATLAB code, what value will be saved in the variable str • Hello World • HelloWorld • [ ] • Will return an error message
Question 21 • What will appear in the command window after executing this code: z=5; fprintf('The answer is z') • The answer is 5 • The answer is z • The answer is 5.00 • Will return an error.
Question 22 • Where is the error: for k=1:3 prompt=('Player #',num2str(k),':'); Play(k)=input(prompt); end • The error is in the FIRST line. • The error is in the SECOND line. • The error is in the THIRD line. • The error is in the FOURTH line.
Question 23 • What is the value stored in the variable chk chk=strcmp(‘yes’,’Yes’) • 0 • 1 • [0 1 1] • [1 1 1]
Question 24 • What is the value stored in the variable chk chk=strcmpi(‘yes’,’Yes’) • 0 • 1 • [0 1 1] • [1 1 1]
Question 25 • What is the value stored in the variable chk chk= (‘Mark’ == ‘mark’) • 0 • 1 • [1 1 1 1] • [0 1 1 1]