Académique Documents
Professionnel Documents
Culture Documents
Software Interface
Workspace:
shows a list of
variables created
by MATLAB.
Software Interface
Software Interface
Workspace: shows a
list of variables
created by MATLAB.
As you can see, the
value of a is shown.
Software Interface
Software Interface
By double
clicking on b, the
variable editor
window appears.
You can type in
new values into b
by filling in the
cells.
Software Interface
By double
clicking on b, the
variable editor
window appears.
You can type in
new values into b
by filling in the
cells.
OR
varA = [1,2,3,4,5,6,7,8,9,10] ;
matrixName(rowNumber, colNumber)
Example: Given a matrix, M as
>> M = [1,2,3,4,5;3,4,5,6,7]
M=
1 2 3 4 5
3 4 5 6 7
Determine value for 2nd row and 4th column
>> ans = M(2,4)
ans =
6
matrixName(rowNumber, colNumber)
Use
>> M = [1,2,3,4,5;3,4,5,6,7]
M=
1 2 3 4 5
3 4 5 6 7
Determine values for 2nd row
>> ans = M(2,:)
ans =
3 4 5 6 7
1
1
0
0
0
>> Z=zeros(3,2)
1 1
1 1
>> K = ones(2, 3)
>> R = rand(3, 3)
Operator
Operator
Mathematical
Mathematical Array
Addition
Addition
Subtraction
Subtraction
Multiplication
.* Multiplication
Division
./ Division
Power
.^ Power
>> Ans2 = M + N
Ans2 =
3 8
8 3
Operator
Mathematical
Mathematical Array
Addition
Addition
Subtraction
Subtraction
Multiplication
.* Multiplication
Division
./ Division
Power
.^ Power
Plotting graphs
Available Plot Formats
plot(x,y)
semilogx(x,y)
semilogy(x,y)
loglog(x,y)
xlabel(TextX)
ylabel(TextY)
subplot(row,col,no)
grid
legend(M,N,K)
Typical Plot
Plotting graphs
>> t = 1:0.5:10;
>> y1 = 2*t.^2 + 2*t + 9;
>> y2 = 3*t.^2 + 0.6*t + 0.1;
Step 2: Now create plot
y1 vs t, and y2 vs t together
>> plot(t,y1,b)
>> plot(t,y2,g)
Step 3: Add title and axis label
>> title(Quadratic plots)
>> xlabel(The x-axis label, t)
>> ylabel(The y-axis label, y)
Starting value
Final value
x = [xi dx xf ]
increment