Matlab Flashcards
(44 cards)
Is matlab compiled or interpreted?
Interpreted, this means it can be run interactively with scripts and by calling functions
clc
clear the command window
clear
clear the workspace (erase all variables from memory)
clear var_name
erase variable var_name from memory
help fcn_name
get basic information about fcn_name
What would A(: , 2) return?
The 2nd column of A
What would A(4 , :) return?
The 4th row of A
What would A(:, 2:3) return?
The 2nd and 3rd columns of A
Where does indexing start in Matlab?
At 1
How do we define character arrays?
With single quotes, for example ‘ENAS130’
What happens if you try to multiply a character array by a scalar?
The ASCII values of the elements of the character array would be multiplied by the scalar
What does size() return?
Returns the number of rows and columns
What does length() return?
Returns the length of the largest array dimension
What does height()/width() return?
Height returns number of rows, width returns number of columns
How do you save data into a .mat file?
save(filename) will save all variables and values currently in the workspace to a .mat file
How do you load data from a .mat file?
load(‘filename’, ‘variables’) if wanting to load specific varaibles, else load filename.mat
How do you view file contents without loading them in?
whos -file filename
How do you save info to a .dat file?
save filename.dat -ascii var1 var2, or without var1 and var2 if you want to save all variables
How do you load data from a .dat file?
load filename.dat -ascii
How do you use colon notation?
initVal : step : endVal
How do you use the linspace function?
linspace(initVal, endVal, length of vector)
How can you easily initialize a vector of equal values?
x = scalar * ones(1,3)
What does max return?
returns the maximum value and its index
What does polyfit do?
finds the best-fit line coefficients