Академический Документы
Профессиональный Документы
Культура Документы
1. Predefined Variables:
MATLAB includes a number of predefined variables. Some of the predefined variables use in
MATLAB programs is summarized in Table below:
Predefined Variables
Ans
Represents a value computed by an expression but not stored in variable
name.
Pi
Represents the number .
inf
Represents infinity which for instance occurs as a result of a division by zero.
A warning message will be displayed or the value will be printed as .
i
Defined as 1, which is: 0 + 1.0000i
J
Same as i.
NaN
Stands for Not a Number.
clock
Represents the current time in a six-element row vector containing year,
month, day, hour, minute, and seconds.
Date
Represents the current date in a character string format.
Workspace information
clear
Removes all variables from the memory.
clear x, y, z Clears/removes only variables x, y and z from the memory.
clear all
Clears all variables and functions from workspace.
Who
Lists the variables currently in the workspace.
Whos
Displays a list of the variables currently in the memory and their size together
with information about their bytes and class.
mlock fun
Locks function fun so that clear cannot remove it.
Clc
Clears command window, command history is lost.
home
Same as clc
Clf
Clears figure window.
On-line help
help
Lists topics on which help is available.
Helpwin
Opens the interactive help window.
help topic
Provides help on topic.
lookfor string
Lists help topics containing string.
Quit
Quits MATLAB
Exit
Same as quit.
1 of 3 Computer application 2
2. Matrix fundamental:
When we enter a matrix we use this expression:
2 1 3
Assume that
A=[
]
4 2 10
The MATLAB input command is
>> A=[2,-1,3;4,2,10]; or A = [2 -1 3;4 2 10];
Similarly, for complex number elements of a matrix B
[d,n]=max(A)
min(A)
[d,n]=min(A)
sum(A)
sort(A)
median(A)
det(A)
dot(a, b)
inv(A)
Example
>> A = [3 7 2 16];
>> mean(A)
ans = 7
>> A= [3 7 2 16 9 5 18 13 0 4];
>> C = max(A)
C=
18
>> [d ,n] = max(A)
d = 18
n=7
3 of 3 Computer application 2