MatLab exam 1
how to plot a log x and linear y plot
semilogx(x,y)
how to plot a linear x and log y plot
semilogy(x,y)
what is run-time error?
when an illegal mathematical operation is attempted (divide by zero)
What is the command for "generating the list of variables in workspace"?
whos
Let c = [3 2]' & d = 5 what us c * d?
c * d = 15 10
What is the difference between right division (i.e., A / B) and left division (i.e., A \ B) in MATLAB? in what case is it used?
(A/B) = A * inv(B) (normal division) (A\B) = inv(A) * B Ay = B, to solve for y , you will input y = A \ B
List 3 ways to "create" and "initialize" a variable in MATLAB
1. assign data to a variable in statement 2. input data from keyboard 3. read data from file
Let: c = [1 2 3 4; 5 6 7 8; 9 10 11 12] what is the size of c?
3 by 4
Let: c = [1 2 3 4; 5 6 7 8; 9 10 11 12] what is the value of c(2,3)?
7
What is the MATLAB "editor"?
A series of commands can be placed into a text file for code development.
How do you abort your code? (2 ways)
CTRL + C type "abort"
What is the MATLAB "workspace"?
It stores variables created in the code and store them
what is NOT the purpose of EGR115
Its NOT the purpose to make you learn how to use MATLAB
Advantages of MATLAB
Its an INTERPRETER; no need to compile, easy to use, platform independent, many pre-defined functions
What is the MATLAB "command window"?
Its an interactive solver, it accepts commands, interpret/execute it, and the outputs results
Spell the actual full name of MATLAB
MATrix LABoratory
how to bold text?
\bf
how to make text italic?
\it
how to create superscripts in text?
^{XXX}
how to create subscript in text?
_{XXX}
Let a = [1 0; 2 1] & b = [-1 2; 0 1] What is a + b?
a + b = 0 2 2 2
Let a = [1 0; 2 1] & b = [-1 2; 0 1] what is a .* b?
a .* b = -1 0 0 1
Let a = [1 0; 2 1] & d = 5 What is a .* d?
a .* d = 5 0 10 5
how do you create an 2 by 3 by 2 array filled with '1'
a = ones(2,3,2)
what is MATLAB
a computer program developed to perform engineering and scientific calculations. Designed to handle matrices.
What is syntax error?
a grammatical error in the statement (spelling, punctuation, format, etc)
What is logical error?
an error with the logic, cannot be detected by MATLAB
What is the result after executing the following: arr1 = [1 2 3 4; 5 6 7 8; 9 10 11 12]; arr1(1:2,[1 4]) = [20 21; 22 23]
arr1 = 20 2 3 21 22 6 7 23 9 10 11 12
The difference between ARRAY and MATRIX
array: operation between arrays on an element-by-element basis matrix: follow linear algebra rules
how to set the axis increments to be equal
axis equal
how to cancel the effect of axis equal and axis square
axis normal
how to turn OFF all axis labeling, tick marks, and background
axis off
how to turn ON all axis labeling, tick marks, and background
axis on
how to make the current axis box square
axis square
how to set the limits of the x and y axis
axis([xmin xmax ymin ymax])
how do you clear the contents of the command window?
clc
How do you clear the workspace?
clear
Let: e = [1 2 3 4; 5 6 7 8; 9 10 11 12] what is e(3,[1 4])?
e(3,[1 4]) = 9 12
Let: e = [1 2 3 4; 5 6 7 8; 9 10 11 12] what is e([1 3],2)?
e([1 3],2) = 2 10
how to graph multiple line in multiple figures
figure => plot => figure => plot
Why do you need to develop MATLAB scripts?
it can be saved and executed in the command window instead of typing everything in the command window.
What is MATLAB script?
its a text file that has a series of MATLAB commands. Its the programming part of MATLAB
disadvantages of MATLAB
its an INTERPRETER; slower than compiled languages, very expensive
What is the purpose of EGR115
learning how to understand and apply computing. Design/develop/debug programs
how to plot a log x and log y plot
loglog(x,y)
what does subplot(2,3,4) do?
opens a new graph figure and creates six regions arranged in 2 rows and 3 columns. in the 4th position it graphs (lower left)
how to graph multiple lines in one figure
plot => hold on => plot => hold off
how to plot a linear x and y
plot(x,y)