Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

MATLAB Commands and Concepts: A Comprehensive Guide for Students, Exams of Nursing

A comprehensive list of matlab commands and concepts, covering various aspects of programming, data manipulation, visualization, and mathematical operations. It serves as a valuable resource for students learning matlab, offering definitions, explanations, and examples of key commands and concepts. Organized in a clear and concise manner, making it easy for students to navigate and understand the information.

Typology: Exams

2024/2025

Available from 03/10/2025

caroline-njeri
caroline-njeri 🇺🇸

176 documents

1 / 13

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
PSU CMPSC200 MIDTERM 2024
QUESTIONS & CORRECT ANSWERS.
ALREADY GRADED A+.
.* - ANSElement-by-element array multiplication operator
.^ - ANSElement-by-element array power operator
* - ANSMatrix multiplication operator
& - ANSAnd (used with vectors)
&& - ANSAnd (used with scalars)
%c - ANSUsed for displaying just one character
%e - ANSExponential notation
%f - ANSFixed-point notation
%g - ANSUsed for displaying the shorter of fixed-point notation or exponential notation
%i - ANSinteger notation
%s - ANSUsed for displaying a string of characters
^ - ANSMatrix power operator
< - ANSLess than
<= - ANSLess than or equal to
== - ANSEquality check
> - ANSGreater than
>= - ANSGreater than or equal to
| - ANSOr (used with vectors)
|| - ANSOr (used with scalars)
~ - ANSNot
pf3
pf4
pf5
pf8
pf9
pfa
pfd

Partial preview of the text

Download MATLAB Commands and Concepts: A Comprehensive Guide for Students and more Exams Nursing in PDF only on Docsity!

PSU CMPSC200 MIDTERM 2024

QUESTIONS & CORRECT ANSWERS.

ALREADY GRADED A+.

.* - ANSElement-by-element array multiplication operator .^ - ANSElement-by-element array power operator

    • ANSMatrix multiplication operator & - ANSAnd (used with vectors) && - ANSAnd (used with scalars) %c - ANSUsed for displaying just one character %e - ANSExponential notation %f - ANSFixed-point notation %g - ANSUsed for displaying the shorter of fixed-point notation or exponential notation %i - ANSinteger notation %s - ANSUsed for displaying a string of characters ^ - ANSMatrix power operator < - ANSLess than <= - ANSLess than or equal to == - ANSEquality check
  • ANSGreater than = - ANSGreater than or equal to | - ANSOr (used with vectors) || - ANSOr (used with scalars) ~ - ANSNot

~= - ANSNot equal to 0 (zero) is the typical computer science representation for true, while 1 (one) is the typical computer science representation for false. - ANSFalse A matrix with a determinant that is non-zero - ANSA matrix for which an inverse does not exist A stiff equation is a differential equation where some numerical solution approaches are numerically stable unless you use extremely small step sizes. - ANSFalse alpha( ) - ANSUsed to adjust the transparency of a graphics object An array cannot contain multiple pieces of information. - ANSFalse animatedline( ) - ANSCreates a line animation Annotation axes - ANSEnables one to insert annotation objects such as lines, legends, and text boxes onto a figure Arithmetic and Logic Unit (ALU) - ANSPerforms mathematical operations Array - ANSContainer for multiple pieces of orderly information At the end of a for loop, the loop index variable keeps its most recent value. - ANSTrue axis( ) - ANSUsed to control the axes of a plot Bit - ANSOne 0 or 1 break - ANSUsed to cause the termination of the smallest enclosing for loop or while loop break and continue are "go-to" techniques that all programmers should readily use. - ANSFalse Built-in backslash operator approach for solving systems of linear equations - ANSsolution = A\b Byte - ANSEight 0 or 1's camlight( ) - ANSUsed to adjust lighting Cell array constructors - ANSCurly braces: { and }

cputime( ) - ANSReturns the total central processing unit time used by MATLAB Cross product - ANSResult is orthogonal to the plane defined by the two input vectors Cross product operation - ANSc = cross(a, b) cumtrapz( ) - ANSCalculates the cumulative sum using the trapezoidal method Curve fitting - ANSConstructs a line of best fit for a data set diff( ) - ANSUsed for creating finite differences diff( ) - ANSUsed to calculate symbolic derivatives disp( ) - ANSUsed for printing output to the screen, but does not generally have formatting capabilities dlmwrite( ) - ANSUsed to write delimited output Dot product operation - ANSc = dot(a, b) Double - ANSIs stored using 64 bits dsolve( ) - ANSUsed to solve symbolic differential equations Edit text box - ANSUsed for acquiring input from the user Effective strategies for improving the performance of MATLAB computer code include: - ANS1. Only printing using print statements

  1. Considering feedback from MATLAB itself
  2. Pre-allocating space for variables elseif (without a space) and else if (with a space) are generally not interchangeable. - ANSTrue etime( ) - ANSPerforms a comparison between a start time and an end time Every while loop can be made into a for loop, but not every for loop can be made into a while loop. - ANSFalse expand( ) - ANSMultiplies out all of the parts of the expression or equation Extrapolating beyond a given data set often results in excellent and useful results. - ANSFalse

Extrapolation - ANSConstructs estimated new data points beyond the range of a data set factor( ) - ANSFactors the expression false - ANSThe logical value 0 Field - ANSCan be thought of as a property fieldnames( ) - ANSAllows one to see the name of the fields figure( ) - ANSCalls a figure, creating it if necessary fimplicit( ) - ANSPlots implicit 2D plots Flowchart - ANSGrapgical representation of how code flows or progresses fmesh( ) - ANSPlots wireframe meshes fplot( ) - ANSPlots 2D plots fplot3( ) - ANSPlots 3D plots fprintf( ) - ANSUsed for printing output to the screen or to a file, and generally has formatting capabilities fsurf( ) - ANSPlots surface plots fzero( ) - ANSUsed for finding roots get( ) - ANSEnables one to acquire graphics object properties ginput( ) - ANSUsed to get data points from a plot gradient( ) - ANSUsed for creating finite differences Handle graphics - ANSThe components of the GUI are stored as properties relating to this idea horzcat( ) - ANSConcatenates horizontally How many counters can be used within a single program? - ANSAs many as the programmer would want or need imread( ) - ANSReads an image from a file

ln(x) - ANSNot a valid MATLAB command log(x) - ANSlog base e of x log10(x) - ANSlog base 10 of x loglog( ) - ANSPlots logarithm of y vs. logarithm of x Main Memory - ANSStores programs and program data into random access memory Mathematical function - ANSA mathematical relationship that maps an input to an output MATLAB array indexes must be positive integers. - ANSTrue MATLAB defaults to the behavior of hidden on unless hidden off is specified. - ANSTrue MATLAB function files are .m files like scripts are. - ANSTrue MATLAB generally interprets computer code line by line from the top to the bottom of a program. - ANSTrue MATLAB's desktop environment is an example of a GUI. - ANSTrue Matrix - ANS2D numeric array used in linear algebra with special mathematical properties Matrix inverse approach for solving systems of linear equations - ANSsolution = inv(A)*b Middle Riemann sum - ANSApproximates the function by its value at the middle point of the subinterval Most efficient approach computationally in MATLAB for solving systems of linear equations - ANSsolution = A\b nargin( ) - ANSDetermines the number of input arguments nargout( ) - ANSDetermines the number of output arguments Neglecting the possibility of else or elseif cases, a while loop can be thought of like a repetitious if statement. - ANSTrue Non-volatile Memory - ANSPermanant data storage num2str( ) - ANSConverts numbers to a character array

Numbers - ANSNumeric data numden( ) - ANSUsed to find the numerator and denominator of an expression Numerical differentation - ANSConstructs estimated derivative data for a data set Numerical differentiation tends to amplify the noise in one's data set. - ANSTrue ode113( ) - ANSA multi-step solver ode15i( ) - ANSUsed for solving implicit differential equations ode15s( ) - ANSGood for solving stiff differential equations and differential algebraic equations ode45( ) - ANSTypically your first choice solver unless you know something special about the ODE or ODE system One must use an even number of intervals when utilizing Simpson's rule. - ANSTrue orderfields( ) - ANSAllows one to reorder the fields Pass by reference - ANSA method for passing data to a function where memory address itself of a variable of interest is sent to the function Pass by value - ANSA method for passing data to a function where a copy of the value of a variable of interest is sent to the function Pass by value is not available in the MATLAB programming language, but pass by reference is. - ANSFalse pathtool - ANSUsed to instruct MATLAB to search for a given function pcolor( ) - ANSCreates a pseudocolor checkerboard plot plot( ) - ANSPlots y-data points vs. x-data points plot3( ) - ANSPlots a 3D plot polyfit( ) - ANSCreates a curve fit polyval( ) - ANSEvaluates the result of a polynomial from its coefficients pretty( ) - ANSPrints symbols in a plain-text format that resembles typeset mathematics

Some functions can have different behavior based on how they are used. - ANSTrue sprintf( ) - ANSUsed for printing output to a text string, and generally has formatting capabilities Static text box - ANSUsed for displaying text to the user String - ANSAn example of a character array Structure array - ANSThe MATLAB-created .m file uses this concept to pass information around the GUI-involved program Subfunctions - ANSThe MATLAB-created .m file uses this concept to organize the sections of the GUI-involved program subs( ) - ANSUsed to substitute in numbers, symbols, or other variable name(s) surf( ) - ANSPlots a 3D surface plot Switches can only check for equality, while if statements can check for equality or inequality. - ANSTrue syms - ANSDeclares a variable as a symbol The choice between numerical integration approaches depends on what the data looks like and what computational expense you can tolerate. - ANSTrue The default angular unit in MATLAB is radians unless specified otherwise. - ANSTrue The difference between for loops, while loop, and do while loops is that for loops ________, while loops _______, and do while loops _______, - ANS1. repeat a block of code a fixed number of times

  1. evaluate a condition before deciding if a block of code is to be run or repeated
  2. execute a block of code, then evaluate a condition to decide if the block of code should be repeated The dimensions of the result from a matrix multiplication operation are determined by the outer dimensions of the two matrices being multiplied. - ANSTrue The do while loop is a useful built-in feature of the MATLAB programming language. - ANSFalse The fact that a global variable is both visible and modifiable to all parts of a program is both an advantage and a disadvantage. - ANSTrue

The input (or output) order must be consistent between a function and whatever calls it.

  • ANSTrue The input( ) command can be used to acquire numeric input from the user. The input( ) command can also be used to acquire character input from the user. - ANSTrue The key difference between animations and movies is that animations ______________ while movies ________________ - ANS1. are drawn live with no archiving
  1. enable archiving The key parts to every function are: - ANS1. The name of the function
  2. The outputs from the function, if applicable
  3. Comments that describe the other parts of the function
  4. The inputs to the function, if applicable The modern approach for symbolically solving ODEs in MATLAB is to use symbolic functions as an input into the built-in differential equation solver command. - ANSTrue The result of a matrix multiplication operation is mathematically defined if the inner dimensions of the two matrices being multiplied are not equal to each other. - ANSFalse The semi-colon at the end of a line of code is generally an optional piece of syntax in the MATLAB programming language. - ANSTrue There are sometimes multiple valid ways to solve the same programming tasks. - ANSTrue There are three primary steps for writing to a file with fprintf(). Which of the following are those steps? - ANS1. Write to the file
  5. Close the file
  6. Open the file, creating it if necessary tic and toc( ) - ANSUsed as a stopwatch feature title( ) - ANSAdds a title to a plot To use MATLAB's built-in numerical ODE solver, one must convert the ordinary differential equation or the system of ordinary differential equations into state-space form. For the purpose of this question, disregard the special case where one is numerically solving a single ODE that is first order. - ANSTrue Transposition (disregard the case of complex numbers) - ANSInterchanges the rows and columns

Which built-in command would you use if you wanted to generate uniformly distributed pseudorandom numbers? - ANSrand( ) Which of the following are characteristics of computers? - ANS1. Do not tire

  1. Follow instructions precisely
  2. Are reliable in most contexts Which of the following are characteristics of syntax errors? - ANS1. The code is written in such a way that MATLAB does not understand what it is being asked to do
  3. Results in a red error message displaying in the Command Window Which of the following are characters that require special formatting to be printed? - ANS1. Single quotation mark: '
  4. Percent sign: %
  5. Backslash:
    Which of the following are important considerations when planning out a GUI-involved program? - ANS1. How to present the program to the user
  6. What the program does
  7. How the program will look Which of the following are true about MATLAB variables? - ANS1. May contain letters or numbers
  8. Must begin with a letter
  9. May end with a letter Which of the following conditions are required for row echelon form? Row echelon form should not be confused with row reduced echelon form. - ANS1. The pivot of a nonzero row is always to the right of the pivot of the row above it
  10. All nonzero rows are above any rows that contain all zeros Which of the following is not true about plotting in MATLAB? - ANSPlotting is not a useful feature in the MATLAB programming language Which of the following purposes can a counter be used for? - ANS1. To keep track of "How many?"
  11. To keep track of "How much?" Which timing approach is most appropriate for measuring wall time, i.e. the amount of "real" time elapsed? - ANStic and toc( ) xor( ) - ANSExclusive or