Engineering 101 MATLAB Exam With Complete
Solutions Latest Update
program - ANSWER a sequence of statements that instruct the computer to do
something.
interactive program - ANSWER Write statements in the terminal. Hitting Return executes
them immediately
script - ANSWER Write a series of statements ahead of time. Execute those statements
sometime later
suppress an output - ANSWER ;;
display - ANSWER produces an output
variables - ANSWER used to store data. refers to some chunk of memory where the
program stores a value. may contain letters of '_'. Case sensitive
ex: x, y, z
expressions - ANSWER used to compute new data
ex: x = 10+5, y = x .* 7.
consist of literals (3, 7.5), variables (a,b,c), and function calls (sin(3), sqrt(x))
assignment - ANSWER used to store a value into a variable
LHS = RHS, work right to left, takes the value of the RHS and stores it into the LHS.
ex: x .* 7 is assigned to y. variable may be re-assigned many times in code
,operators - ANSWER form compound expressions (+, *, -, etc)
whos - ANSWER used to get information about a variable, including the type of data it
currently stores
orange line around = - ANSWER warning, code will still run
comments - ANSWER use the % symbol. anything after the % until the end of the line is a
comment, comments are ignored by the program but are more for the human reader of
the code to help manage complexity
scalar - ANSWER single number or element
vector - 1 dimensional sequence of numbers or elements, numbers or elements can be
separated with spaces or commas
matrix - 2 dimensional grid of numbers or elements, you separate rows using ; or a new
line. you can use smaller matrices as components, if things doesn't line up, you get an
error
ex: 1:3:12 outputs [1,4,7,10], if the step is omitted it defaults to one
(') - ANSWER transpose operation takes a matrix and produces a copy with the rows
turned into columns
flipud - ANSWER flips the rows up/down
, fliplr - ANSWER flips columns left or right
array - ANSWER everything in matlab is an array. scalar = 1x1, vector = mx1 or 1xn,
matrix is mxn
zeros(m,n) - ANSWER returns an m x n matrix of zeros
zeros(m) - ANSWER returns a matrix of zeros using m for both rows and columns
ones(m,n) - ANSWER returns a m x n matrix of ones
ones(m) - ANSWER returns a matrix of ones using m for both rows and columns
magic(s) - ANSWER returns an s x s magic matrix. magic because each column sum =
each row sum = each diagonal sum.
repmat(A,xTimes,yTimes) - ANSWER makes a new matrix based on repeating matrix A a
certain number of times in the x direction and y direction
reshape(A,numRows,numCols) - ANSWER creates a new matrix with the same elements
as A, but the requested number of rows and columns. The dimensions must match up
with the original number of elements in A.
numel(x) - ANSWER gives the number of elements in x
length(x) - ANSWER gives the number of elements along the longest dimension of x
size(x) - ANSWER returns a vector with the number of elements along each dimension of
The benefits of buying summaries with Stuvia:
Guaranteed quality through customer reviews
Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.
Quick and easy check-out
You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.
Focus on what matters
Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!
Frequently asked questions
What do I get when I buy this document?
You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.
Satisfaction guarantee: how does it work?
Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.
Who am I buying these notes from?
Stuvia is a marketplace, so you are not buying this document from us, but from seller Easton. Stuvia facilitates payment to the seller.
Will I be stuck with a subscription?
No, you only buy these notes for $14.99. You're not tied to anything after your purchase.