Podcast
Questions and Answers
What is the primary use of MATLAB?
What is the primary use of MATLAB?
What is the correct format for using the colon operator in MATLAB?
What is the correct format for using the colon operator in MATLAB?
Which of the following statements about variable names in MATLAB is true?
Which of the following statements about variable names in MATLAB is true?
Which MATLAB window would you use to issue commands during a session?
Which MATLAB window would you use to issue commands during a session?
Signup and view all the answers
What is the highest precedence operator in MATLAB's arithmetic operations?
What is the highest precedence operator in MATLAB's arithmetic operations?
Signup and view all the answers
What would be the output of the expression 2^3 in MATLAB?
What would be the output of the expression 2^3 in MATLAB?
Signup and view all the answers
What is the default data type for variables in MATLAB?
What is the default data type for variables in MATLAB?
Signup and view all the answers
Which of the following commands would correctly create a 2x2 matrix in MATLAB?
Which of the following commands would correctly create a 2x2 matrix in MATLAB?
Signup and view all the answers
Which function would you use in MATLAB to generate linearly spaced vectors?
Which function would you use in MATLAB to generate linearly spaced vectors?
Signup and view all the answers
What happens to commands entered in the Command Window at the end of a session?
What happens to commands entered in the Command Window at the end of a session?
Signup and view all the answers
Study Notes
Exam 2 Information
- Exam 2 short answer portion graded and scantrons submitted to Schreyer Institute.
- Project 4 due on 11/15, involves C++ arrays and will be posted tonight.
- Excel spreadsheet will be posted later this week to help students assess their progress due to late drop deadline approaching.
MATLAB Overview
- MATLAB is short for Matrix Laboratory.
- Designed for easy matrix and array use.
- Excellent for numerical calculations and plotting.
- An interpreted language.
MATLAB Windows
- Command Window: Used to issue commands; simple calculations; deleted when session ends.
- Current Folder Window: Lists current folder contents; default is X-drive; should be set to USB or V-drive.
- Workspace Window: Shows current variables and their properties.
- Command History Window: Records commands issued from session to session.
Arithmetic Operators
-
Exponentiation has highest precedence, followed by division (both left and right) and multiplication; then addition and subtraction.
- Matrix operators operate on the entire matrix or scalar.
- Array (element-by-element) operators perform operations on corresponding elements.
MATLAB Variables
- Variable names can be any length but only the first 63 characters determine uniqueness.
- Variable names consist of letters, digits, or the underscore character; must start with a letter.
- MATLAB variables are automatically treated as a matrix (array) of doubles.
- Variable names cannot be MATLAB keywords.
Creating Matrices and Arrays
- Enclose values in square brackets, separated by spaces or commas.
- For systematic arrays, use colon operator, linspace, or logspace functions.
-
colon_operator
:start:step:stop
; default step is 1. -
linspace(start, stop, number_of_elements)
: Linearly spaced values. -
logspace(start, stop, number_of_elements)
: Logarithmically spaced values in powers of 10.
-
- Rows separated by semicolons (;).
Formatting Commands
- Control how values are displayed; do not alter stored values.
Saving Work
- Access command history in the History window.
- Create MATLAB diary files.
-
save <filename>
saves all variables listed in the workspace. -
save <filename> variable_list
saves specific variables in a file with extension *.mat - save
variable_list – asci saves specific variable in ascii file (read by notepad, etc.). - Use the load command to load saved variables.
Creating Script Files
- Script files contain commands to solve tasks; can be rerun to repeat commands.
- Lab 10, makeup labs 8-10, and Project 5 will likely be submitted as script files.
- Script files are ASCII (text) files, readable/editable in Notepad, Wordpad, etc.
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.
Related Documents
Description
This quiz covers the fundamentals of MATLAB, including its various windows and arithmetic operators. It provides insights into using MATLAB for numerical calculations and the handling of arrays. Ideal for students aiming to enhance their understanding of MATLAB's features.