First Year Flashcards
x = sum (y)
sums the vector y or will sum the values in each column
x = abs (y)
returns the absolute value of y
x = sign (y)
will create a random number
[max, ind] = max (y)
will return the maximum value of and the index. if it is a matrix the max value of each column will appear
For angles which convention is used?
Radians
format for a for loop
for variable = index_values
»code statement referencing index
» end
format for a while loop
> > while (expression)
statements
end
Break function
Jumps out of the loop
Continue Function
goes back to the start of the loop and executes the next iteration without running the remaining code
Return Function
Will return the currently running code
Which function takes precedence in and/or
and takes precedence so bracketing can be used to manually set the order
Indexing formats
CSV is zero
MATLAB is one index
DLM is one index
format for saving a text file
> > save (‘mydata.txt’, ‘-ascii’)
Load command format and use
> > load mydata.mat variable 1
where:
mydata is the filename
variable 1 is what wants to be retrieved
Whats the import wizard used for?
To import a variety of files including images
What is different for the format of how string values are coded
Curly brackets must be used
format for a User Defined Function
> > function y = function name (x)
%comments describing what the function does
code for function
where
y is the output
x is the input argument/s
and the file name should be the same as the function name
How to create a vector of length 10 starting at 2 with an increment value of 6
> > v = linespace (2,6,10)
What does »_space; if a>=b ¦ c ~= b mean in words
is a id bigger or equal to b or c is not equal to b
Under which conditions do logical and relation operators return 1 and 0’s
when they are used outside for and while loops
How do double operators work with scalars
in a&&b if a is false then b isn’t seen to
or a¦¦b if a is true b isn’t evaluated
format for csv read
> > variable = csvread (‘file.csv’ R,C,[R1,C1,R2,C2])
R,C is the index of where the file wants to be read from
R2, C2 is where the read function wants to be ended
Why are user defined functions used?
Portability
Readability
Reliability
What does a red error bar mean?
it signifies an actual error, meaning the function will not run