Professional Documents
Culture Documents
Lab Report Template (SNS)
Lab Report Template (SNS)
Lab Report # 1
Lab. Experiment Name
>> v(:)
First of all we declare a vector matrix and then after using the command the output is given
below. If we suppose a vector it simply convert rows into coloumn.
>> v=[2 3 3 4]
v=
2 3 3 4
>> v(:)
ans =
2
3
3
4
Converts the rows into single coloumn if we suppose a vector but in case of matrix which is not a vector
so this
This command converts the whole matrix entries into one coloum and rows dependent of size of matrix
by lining up column
Wise .so this commands convert the whole matrix entries into one colum and rows depend upon the
size of matrix . in case of vector rows into single column
Linspace(2,30)
The result is a row vector between 2 and 30 with the equally spaced gap of 100 means that interval are
100 each one of equal space
>> linspace(2,150)
ans =gb
Columns 1 through 19
2.0000 3.4949 4.9899 6.4848 7.9798 9.4747 10.9697 12.4646 13.9596 15.4545 16.9495
18.4444 19.9394 21.4343 22.9293 24.4242 25.9192 27.4141 28.9091
Columns 20 through 38
30.4040 31.8990 33.3939 34.8889 36.3838 37.8788 39.3737 40.8687 42.3636 43.8586
45.3535 46.8485 48.3434 49.8384 51.3333 52.8283 54.3232 55.8182 57.3131
Columns 39 through 57
58.8081 60.3030 61.7980 63.2929 64.7879 66.2828 67.7778 69.2727 70.7677 72.2626
73.7576 75.2525 76.7475 78.2424 79.7374 81.2323 82.7273 84.2222 85.7172
Columns 58 through 76
87.2121 88.7071 90.2020 91.6970 93.1919 94.6869 96.1818 97.6768 99.1717 100.6667
102.1616 103.6566 105.1515 106.6465 108.1414 109.6364 111.1313 112.6263 114.1212
Columns 77 through 95
115.6162 117.1111 118.6061 120.1010 121.5960 123.0909 124.5859 126.0808 127.5758 129.0707
130.5657 132.0606 133.5556 135.0505 136.5455 138.0404 139.5354 141.0303 142.5253
>> A = [1 2 3; 4 5 6; 7
8 9]
>> A = [1 2 3; 4 5 6; 7 8 9]
A=
1 2 3
4 5 6
7 8 9
B=
4 5
7 8
The output of the program is that we have a 3*3 matrix stored in A and in B we are storing that go to 2
(Second) row of matrix A and store the entries of first and second entry of row 4 which has column 1
and 2 and also go to 3 (third ) row of matrix A and store the first and secod entries of row 3 (third)
>>
size(A)
It will simply display the size of matrix in short order of matrix that how many rows and how many
coloumn did the matrix have.
For example
>> A = [1 2 3; 4 5 6; 7 8 9]
A=
1 2 3
4 5 6
7 8 9
>> size(A)
ans =
3 3
Task (4): Type the following commands and observe the plot
»t=
-5:.01:5;
» y = sin
(2*pi*t);
» plot
(t,y);
» z = cos
(2*pi*t);
»
plot(t,y,'r',t,z,'k')
The interveel is set on x-axis from -5 t0 +5 with the space between intervals of .01
>>
figure(1)
>> y = [0 1 2 4 2 1
0];
>>
subplot(2,2,1);
>>
stem(y)
>>
subplot(2,2,2);
>>
plot(y)
>>
figure(2)
>> y = [0 1 2 4 2 1
0];
>>
stem(y)
>> hold
on
>>
plot(y)
>> hold
off
STEM
Stem command is used where we need discrete plotting for example on evey interval what was the
point or what was the value of y axis wrt x axis that what is the value of y axis at the define intervals of x
axis (data sequence) .so stem command Is used where we want detail or discrete ploting. Or where we
need finite value.
FIGURE
Figure command is used when we are ploting more than one grafh and compiler only plots the last plot
command by replacing the previous plot command so we cannot see the grafh of first plot so figure is
used before the plot command so that compiler know this is figure(1) or show this grafh as figure one
and for nther plot we use figure(2) so that compiler after running show two windows with the two plots
one in figure one and other in figure two.
HOLD
Hold command is used where we want in one graph two ploting this is done by command hold when we
use hold on this hold the previous plot or graph and add another plot in the same grafh without
replacing the previous graph
Subplot(r,c,p)