Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Basic Plotting
EE 290 Class Notes
Returns
Returns an
an m-by-n
m-by-n matrix
matrix with
with 11 on
on the
the main
main diagonal
diagonal
Returns
Returns an
an n-by-n
n-by-n square
square identity
identity matrix
matrix
Returns
Returns an
an m-by-n
m-by-n matrix
matrix of
of zeros
zeros
Returns
Returns an
an m-by-n
m-by-n matrix
matrix of
of ones
ones
Extracts
Extracts the
the diagonal
diagonal of
of matrix
matrix A
A
Returns
Returns an
an m-by-n
m-by-n matrix
matrix of
of random
random numbers
numbers
Submatrix
>>B=A(1:height/2,
>>B=A(1:height/2, 1:width/2);
1:width/2);
Q:
Q: What
What is
is the
the relation
relation b/w
b/w A
A
and
and B?
B?
Q:
Q: What
What is
is the
the relation
relation b/w
b/w A
A
and
and B?
B?
>>[height,
>>[height, width]=size(A)
width]=size(A)
>>A=rand(4,4);
>>A=rand(4,4);
>>B=A(1:2:height,
>>B=A(1:2:height, 1:2:width);
1:2:width);
>>B=A([1
>>B=A([1 44 33 2],
2], :);
:);
Concatenating matrices
Matrices can be created using other
matrices
Example
Example 1:
1:
Example
Example 2:
2:
>>A=[1
>>A=[1 22 ;; 33 4];
4];
>>A=ones(3,3);
>>A=ones(3,3); B
B == zeros(3,3);
zeros(3,3);
>>B=[
>>B=[ A
A 2*A;
2*A; A
A 2*A];
2*A];
>>C=[
>>C=[ A
A B;
B; B
B A];
A];
>>
>> xx == [1
[1 22 33 44 55 6];
6];
>>
>> yy == [3
[3 -1
-1 22 44 55 1];
1];
>>
>> plot(x,
plot(x, y,
y, o)
o)
X coordinates
format
y coordinates
4
3
2
1
0
-1
yellow
yellow
magenta
magenta
cyan
cyan
red
red
green
green
blue
blue
white
white
black
black
Symbol
Symbol
line
line type
type
.. point
-point
oo circle
::
circle
xx x-mark
-.-.
x-mark
++ plus
-plus
-** star
star
ss square
square
dd diamond
diamond
vv triangle
triangle (down)
(down)
^^ triangle
triangle (up)
(up)
<< triangle
triangle (left)
(left)
>> triangle
triangle (right)
(right)
pp pentagram
pentagram
hh hexagram
hexagram
solid
solid
dotted
dotted
dashdot
dashdot
dashed
dashed
Data set 2
Data set 3
Position of current
subplot
Example:
Example: For
For the
the 33 data
data sets
sets on
on the
the
previous
previous example,Using
example,Using subplot
subplot to
to
plot
plot them
them separately
separately
>>
>> subplot(3,1,1);
subplot(3,1,1);
>>
>> plot(x,y1);
plot(x,y1);
>>
>> subplot(3,1,2);
subplot(3,1,2);
>>plot(x,y2);
>>plot(x,y2);
>>
>> subplot
subplot (3,1,3);
(3,1,3); plot(x,y3);
plot(x,y3);