1 / 53

Exam 3: Review (part 1)

Exam 3: Review (part 1). Test 1 - Outcomes. Computers & Solutions Understand the basic concepts of a computer: the hardware, the software, the different languages. List and follow the steps to solving a problem Apply problem solving approach

miles
Download Presentation

Exam 3: Review (part 1)

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. Exam 3: Review (part 1)

  2. Test 1 - Outcomes • Computers & Solutions • Understand the basic concepts of a computer: the hardware, the software, the different languages. • List and follow the steps to solving a problem • Apply problem solving approach • Identify different strategies to frame problems • Variables & Data Types • Identify the different windows in MATLAB • Create and assign values to variables in MATLAB • Utilize variables for basic calculations

  3. Test 1 - Outcomes • Inputs & Outputs • Give the user the ability to enter words • Show results to the screen:  • for the purpose of debugging (i.e. finding errors in the code) • to show values only • to format a sentence that shows result • Operators & Conditionals • Understand 0 and 1. False and True • Write conditional statements using appropriate operator syntax • Know and apply the syntax of an ifand switch statement: • what keywords are mandatory • what keywords are optional • what order do the keywords go in?

  4. Review Questions CPU stands for _______________________. • Counter productive units • Central processing unit • Copper Part Unit • None of the answers are valid

  5. Review Questions • A TYPICAL keyboard is considered to be: • Input device • Output device • Input/output device • None of the above www.wikipedia.com

  6. Review Questions Which command creates a variable named age, assigns the value 29, and suppresses the output? • Age = 29 • age =29 • 29 = age; • None of the options are valid

  7. Review Questions Which of the following is NOT a valid variable name? • $_money • 2TypesOfRockets • Input • i • j • Name 1

  8. Review Questions Which of the following are Boolean Operators? How about relational operators? • +-*/ • <= >= < > == ~= • || && ~ • None of the above are valid

  9. Review Questions Will the following script file allow the user to enter her/his name properly? clc clear name = input(‘Enter your name’); fprintf(‘Welcome %s!\n’, name); • Yes • No

  10. Review Questions Will the following script file allow the user to enter her/his name properly? clc clear name =input(‘Enter your name’,’s’); fprintf(‘Welcome %s!\n’,name); • Yes • No

  11. Review Questions • 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.

  12. Review Questions • What are some methods to display results? • Which method allows to print results with a specific format? • What are the 4 common placeholders? • What is the purpose of placeholders? • Which function actually uses placeholders? • What are format modifiers? • Which placeholder can have a format modifier that controls the number of decimal places? • If there are 3 placeholders in the control string, how many variables can be printed to the screen?

  13. Review Questions • What are the two conditionals shown that allow to skip code? • Regardless whether it is if or switch, which keyword is always associated with both? • What other keywords are associated with if? • What other keywords are associated with switch?

  14. Review Questions Why does the following script result in an error? clc clear X = input(‘Enter a value: ’); if X = 2 disp(‘2’) else disp(‘error’) end

  15. Review Questions • Is each statement valid? Which will create a string? • x = “EGR 115” □ Valid □ Invalid □ String □ Not a string • x = ‘EGR 115’ □ Valid □ Invalid □ String □ Not a string • x = sprintf(‘ %s %d’,class_name,class_num) □ Valid □ Invalid □ String □ Not a string • x = str2num(‘115’) □ Valid □ Invalid □ String □ Not a string • x=num2str(‘115’) □ Valid □ Invalid □ String □ Not a string • X=double(‘EGR’) □ Valid □ Invalid □ String □ Not a string

  16. Test 2 - Outcomes • Library Functions • Recognize function vocabulary words • variable collections, function call, arguments • Understand how a function works overall • Know and apply the functions that can round up/down/w.r.t 0.5 • Generate a random value between two specific limits • Know the syntax of and purposes of the mod() function • Loops • Recognize when a loop is useful • Write and apply the syntax of a for loop and a whileloop appropriately • Develop an algorithm to solve a problem using a for and whileloops • Understand and apply running totals

  17. Test 2 - Outcomes • Numerical Methods • Know when numerical methods are used • What loops are used and how • Arrays • Recognize when an array is useful • Create scalars, vectors, matrices, transpose • Use functions on arrays  • Augment, concatenate, and diminute arrays

  18. Review Questions • What are the possible outcomes of the following code Rand_num= round((rand*4)+6) • 6,7,8,9 • 7,8,9,10 • 7,8,9 • 6,7,8,9,10 • None of these

  19. Review Questions Which loop form is best for this client’s demand: “Add up all of the values the user provides, stopping when they’ve entered the known number of values” • for • while • if • None of these answers are valid

  20. Review Questions • What is the running total? sum=0; for k=1:5 sum=sum+k*2; end • What is the running total? sum=0; for k=1:5 sum=k+k; end

  21. Review Questions • MATCH: • ( ) 1. Access content of a cell in a cell-array • [ ] 2. array referencing • { } 3. creating normal arrays, and concatenating

  22. Review Questions • What is a vector( row vector or column vector)? • How to create a vector? • What is a matrix ? • How to create a matrix? • How to refer/replace the element(s) in a vector/matrix? • How to define new columns? • How to define new rows?

  23. Review Questions [ ] Given 1 5 6 dataM= 8 9 0 4 3 2 • How do we access/reference element 0? • How do we extract vector ? • How do extract vector • How do we extract matrix ? • How do we extract matrix ?

  24. Review Questions • Will the following operations work? What is the size of the final result? [1 2 3].*[2 3 4] [1 2 3]*[3 4 5] [1 2 3]*[1;2;3] [1 2;3 4; 5 6]*[5 6; 7 8; 9 0] [1 2;3 4; 5 6]*[1 2 3;3 4 5] [1 2;3 4; 5 6].*[5 6; 7 8; 9 0]

  25. Test 3 - Outcomes • File I/O • Utilize and apply files appropriately • Know when and how to use dlmread()or xlsread() • Apply logical operations on arrays • Dialog Boxes • Select and apply the appropriate dialog box • Know how to format dialog boxes • Know what data type is returned by a dialog box input • Strings • Know how to harcodestrings • Know how to prompt the user for strings • Recognize and apply functions used specifically for strings • Know how to compare strings together • Augment, concatenate, diminute strings

  26. Test 3 - Outcomes • Functions • Recognize when and how to apply functions • Know the syntax of creating and calling functions • Understand the unique way that data flows in and out of a function • Create and call functions with multiple inputs and return values • Know how to ignore return values • Plotting • Create arrays to plot data • Know and apply functions to plot data • Low Level Files • Recognize when to use low-level functions • Know and apply the commands needed to open, read, write, append, and close a file

  27. Review Questions • Consider the following MATLAB code, and decide which type of data you are collecting R = xlsread('myFile.xlsx'); • numerical • strings • Cell array • Choice a & c are correct.

  28. Review Questions • Assume the file is the following: • What will be the result of this command: >> [x1, x2] = xlsread(‘data.xlsx’) B? A?

  29. Review Questions • inputdlg() accepts its input arguments as ____________ and return a __________ of ___________. • msgbox() accepts _____________ as its input arguments (data type) (data type) (data type) (data type)

  30. Review Questions • What value will be in the variable len after executing this MATLAB code? • 10 • 11 • 12 • 13

  31. Review Questions • After running this MATLAB code, what value will be saved in the variable str_edit • Hello Wo • lo W • lo Wo • loWo

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

  33. Review Questions • After running this MATLAB code, what values will be saved in the variable str1 and str2 • str1: ‘Hello ’, str2: ‘ World’ • str1: ‘Hello’, str2: ‘World’ • str1: ‘Gdkkn’, str2: ‘Vnpkc’ • None of these

  34. Review Questions • What is the value stored in the variable chkchk=strcmp(‘yes’,’Yes’) • 0 • 1 • [0 1 1] • [1 1 1] • It cannot be determided

  35. Review Questions • What is the value stored in the variable chkchk=strcmpi(‘yes’,’Yes’) • 0 • 1 • [0 1 1] • [1 1 1]

  36. Review Questions • What is the value stored in the variable chkchk=strcmp(password,‘hd93yf8’) • 0 • 1 • [0 1 1] • [1 1 1] • It cannot be determined

  37. Review Questions • What is the value stored in the variable chk chk= (‘Mark’ == ‘mark’) • 0 • 1 • [1 1 1 1] • [0 1 1 1]

  38. Review Questions • The part that is circled is called: function W = M (A,B) • function • Return variables • Function name • Parameters

  39. Review Questions • The part that is circled is called: function W = M (A,B) • function • Return variables • Function name • Parameters

  40. Review Questions • The part that is circled is called: W = MyFun (A,B) • Function call • Return values • Arguments • Parameters

  41. Review Questions • The arguments’ names in the function call MUST match the parameters’ name in the function header? • In the function header, how many parameter can the function have? How many return values can the function have? • Does the number of return values in the function header need to match the number of the collection values in the function call?

  42. Review Questions • 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.

  43. Review Questions • polyfit() will return the coefficient of the polynomial that best fits the data given. • TRUE • FALSE

  44. Review Questions • Which of the following built-in function, will CREATE a plot. • polyval() • polyfit() • xlabel() • polar()

  45. Review Questions In the following syntax, __C__= fopen(___A_____, _ B__) • MATCH: _____ The permission string _____ The file’s actual name _____ The file identifier (i.e. cursor position)

  46. Review Questions • When using the ‘r’ access-mode (i.e. permission), the initial position of the pointer (i.e. cursor) 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)

  47. Review Questions • 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

  48. Review Questions • 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

  49. Review Questions • 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?

  50. Review Questions The file contains the retired hurricane names, and the year they were retired: Assume the data has been properly uploaded using textscan() and extracted into Col1, and Col2. Which command(s) would find the year a specific name has been retired? For example: NameUserChose = ‘Lili’; • if Col1 == NameUserChose • disp(Col2) • end • B. Year = Col2(strcmp(Col1,NameUserChose)); Row = find(strcmp(Col1,NameUserChose)); year = Col2(Row);

More Related