MATLAB,
on opening, shows 2 screens, one of which is the command window and the other
is the editor.
The
command window is used to execute all the commands, while the editor is used to
write your code.
When
some basic commands are entered on the command window, a result corresponding
to the command is displayed. The command window can perform basic operations
like addition, subtraction, multiplication, division, logarithm etc.
">>"
is known as the command prompt. It appears automatically on every new line in
the command window.
For example,
when we enter "2+3" in the command window, the value 5 will be
assigned to a variable.
"Ans"
is a default variable, and the value is assigned to this variable if no other
is specified.
>>2+3
>>Ans
=
>>
5
BASIC
COMMANDS IN MATLAB
A few
basic commands of MATLAB are -
clock
- Gives the date and time as a vector
date
- gives the current date
ver -
displays the current version of MATLAB installed
dir -
displays files or folders in the current directory
ls -
lists the files or folders in the current directory
pwd -
gives the path of the present working directory
cd(path)
- changes the directory to the path given inside the brackets (if the path is
not specified, the directory doesn't change)
path
- Gives the path to the current directory
editpath
- opens a window to change the path
mkdir
filename - creates a directory with the given name
copyfile
filename1 filename2 - copies one file to another
who -
gives the variables in the workspace (variables that are being used at present)
whos
- displays the variables in the workspace with type and size
what
- displays the .m,.mex and .math files
Mathematical Functions used in MATLAB -
Some of the basic mathematical functions in MATLAB are:
sqrt(x)
- to get the square root of x
exp(x)
- to calculate exponent (e^x)
abs(x)
- to get absolute value of x
log(x)
- log base e of x
log
10(x) - log base 10 of x
factorial(x)
- factorial of x
round(x)
- gives the rounded value of x
ceil(x)
- gives the closest integer greater than x
fix(x)
- gives the closest integer lesser than x
For example,
>>
17/5
>>
Ans =
>>
3.4
>>
round(17/5)
>>
Ans =
>>
3
>>
ceil(17/5)
>>
Ans =
>>
4
>>
fix(17/5)
>>
Ans =
>>
3
The basic commands and mathematical functions, if entered in the command window, produce the desired result. These can also be used in the text editor window as a part of a program code.
0 comments:
Post a Comment