The "clc" (clear command window) command clears the screen.
The word of "workspace" refers to the set of variables created, and the "clear" command removes all the variables. To remove a specific variable, type "clear variable_name".
"Tool strips" include "HOME", "PLOTS" and "APPS".
Notes from the Coursera course "Introduction to Programming with MATLAB"
To use the command of "save" to save variables in the work space to a disk space, and to use the command of "load" to load saved variables back into the work space.
"," and ";" both separate commands. The difference is that ";" silences "echo" but ''," does not.
"..." allows continuity onto the next line.
"help command_name" and "doc command_name" to see the help page for the command in the basic and the fancy forms respectively.
The "length" function shows the number of elements in a vector.
The "figure" command opens a new figure for plotting.
The "close(1)" command closes the "figure 1", and the "close all" command closes all figures.
The "imread(image_name)" command reads in numbers stored in an image and prints these numbers to the screen.
To see the image of the variable read in by the "imread" function, use the command of "image(variable_name)".
To remove axis from the image, use the command "axis off".
"pi" is a built-in function.
"sqrt": the square root function.
"sin": the sin function of radians.
"sind": the sin function of degrees.
"size": prints out the dimension of a matrix.
In the matrix format, ";" denotes the end of a row.
The colon operator for generating a series of numbers with a certain step takes the form of start:step:end. The short form of specify a step of "1" is start:end.
An operator is a function invoked by a symbol.
The "+" operator works the same way as the "plus" function.
The ":" operator works the same ways as the "colon" function.
Input to an operator are called "operands", and are separated by the operators themselves.
To index an element of an matrix using the form "matrix(row_num,col_num).
"end" is a key word in Matlab that has special meaning of the last index.
"*" is reserved for matrix multiplication, and ".*" is reserved for array multiplication.
"./" and ".\" indicate array division (over and under).
".^" indicates array exponentiation.
"rand(row_num,col_num)" creates a (row_num X col_num) matrix of random numbers between 0 and 1.
The "edit" command opens up the editor window.
Formal Definition of Function:
function [out_arg1, out_arg2, ...]=function_name (in_arg1, in_arg2, ...)
The built-in function "exist" can be used to check if a function name refers to a built-in function. More information is available from "help exist".
Only the first function in a Matlab m-file can be called from outside.
In Matlab, global declaration can't be combined with an assignment operation.
A script is different from a function, in that
(1) A script never returns a value or accepts an input argument.
(2) The scope of the script is the scope of the command window.
Polymorphism refers to (1) the type of an input argument to a function varies from one call to another, and (2) variation in the number of arguments from call to call.
The "randi" function provide random integers, and the first argument is the maximum number ranging from 1 to the maximum number.
The "randn" function generates random number of normal distribution.
The MATLAB pseudo random number generator can be initialized with the built-in function "rng".
The "hold on" command ensures subsequent plots are plotted on the same figure. The "hold off" will turn off addition of plots to the figure, and if the same figure is active, will replace the existing plots in the figure.
The command "dbquit" quits debugger.
Combining multiple logical values using "&&", "||", and "~", and for the array version, "&" and "|" are in effect.
The built-in function "nargin" returns the number of input arguments a function was called with.
The built-in function "nargout" returns the number of output arguments a function caller requested.
The built-in function 'isscalar" check if an input argument is a scalar.
The built-in function "fix" rounds the input argument to an integer.
The persistent variable in MATLAB is a local variable but the value is persistent from one call of the function to the next.
The "clear accumulate" reset the persistent variable.
The "section" in MATLAB begins with "%%", and ends with the beginning of the next section or the end of the file.
The "tik" and "toc" functions can be used to start and end timer respectively.
The function "whos" prints out the existing variables in the current workspace.
Type check function: "isa(x,'double')".
Range check functions:
intmax, intmin,realmax,realmin
Data type conversion function:
int8, uint32,double...
No comments:
Post a Comment