Professional Documents
Culture Documents
Introduction to MATLAB
‘help’ command:
The command help matlab iofun will display input/output
information. To get help with other MATLAB topics, we
can type help followed by any topic from the displayed
menu. For example, to get information on graphics, we
type help matlab graphics.
Exiting MATLAB:
When we are done and want to leave MATLAB, we type quit
or exit.
‘clear’ command:
If we want to clear all previous values, variables, and
equations without exiting, we should use the clear
command. This command erases everything; it is like
exiting MATLAB and starting it again.
‘clc’ command:
The clc command clears the screen but MATLAB still
remembers all values, variables and equations which we
have already used.
Example:
Evaluate polynomial x2+2x+1 at x = 2.
>> e=[1 2 1]; % defining polynomial
>> f=polyval(e,2) % define polynomial and evaluation value
f =
9
Example:
>> p1=[1 -3 0 5 7 9];
>> p2=[2 0 -8 0 4 10 12];
>> roots_num= roots(p1)
roots_num =
2.4186 + 1.0712i
2.4186 - 1.0712i
-1.1633 + 0.0000i
-0.3370 + 0.9961i
-0.3370 - 0.9961i
Command Description
xlabel(txt) It labels the x-axis of the
current axes.