1 / 26

REVIEW 1 EXAM 3

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

dagmar
Download Presentation

REVIEW 1 EXAM 3

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. REVIEW 1 EXAM 3

  2. 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

  3. 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}

  4. Question 3 • A TYPICAL keyboard is considered to be: • Input device • Output device • Input/output device • None of the above www.wikipedia.com

  5. 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)

  6. 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

  7. 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

  8. Question 7 • The part that is circled is called: function W = M (A,B) • function • Return variables • Function name • Parameters

  9. 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?

  10. 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?

  11. 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?

  12. Question 11 • Which of the following built-in function, will CREATE a plot. • polyval() • polyfit() • Xlabel() • polar()

  13. 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.

  14. Question 13 • The part that is circled is called: function W = M (A,B) • function • Return variables • Function name • Parameters

  15. Question 14 • The part that is circled is called: W = MyFun (A,B) • Function call • Return values • Arguments • Parameters

  16. Question 15 • polyfit() will return the coefficient of the polynomial that best fits the data given. • This statement is TRUE • This statement is FALSE

  17. 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.

  18. Question 17 • What value will be in the variable len after executing this MATLAB code: • 10 • 11 • 12 • 13

  19. 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

  20. Question 19 • After running this MATLAB code, what value will be saved in the variable str_edit • Hello Wo • lo W • lo Wo • loWo

  21. Question 20 • After running this MATLAB code, what value will be saved in the variable str • Hello World • HelloWorld • [ ] • Will return an error message

  22. 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.

  23. 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.

  24. Question 23 • What is the value stored in the variable chk chk=strcmp(‘yes’,’Yes’) • 0 • 1 • [0 1 1] • [1 1 1]

  25. Question 24 • What is the value stored in the variable chk chk=strcmpi(‘yes’,’Yes’) • 0 • 1 • [0 1 1] • [1 1 1]

  26. Question 25 • What is the value stored in the variable chk chk= (‘Mark’ == ‘mark’) • 0 • 1 • [1 1 1 1] • [0 1 1 1]

More Related