MAT Lab
MAT Lab
EQUIPMENT REOUIRED:
Personal computer
Operating system windows 8
MATLAB Software-version R2007b
THEORY:
Linespace - Generate linearly spaced vectors,
Syntax
Y = linespace(a, b)
Y = linespace(a, b, n)
Description
The linespace function generates linearly spaced vector. It is similar to the colon operator":",
but gives direct control over the number of points.
Y = linespace(a, b) generates a row vector y of 100 points linearly spaced between and
including a and b.
Y = linespace(a, b, n) generates a row vector y of n points linearly spaced between and
including a and b.
When executed, produces a vector having 5 equally spaced elements between the limits 0 and
10 given as follows a = [0 2 5 7.5 10.0]
MATLAB PROGRAMMING:
DISCUSSION OUESTION:
(i) Obtain the following products
a) AB b) ATA
3
Where A= 2 , B=[ 6 1 0 ]
1
3 0 −2
2 4
(ii) Find determinants and inverse of each matrices, A= , B= −1 1 2
8 −1
0 1 −2
[EXPERIMENT No: 6]
MATLAB PROGRAMMING
Plot the Sine function over the domain -x ≤ x ≤ x
x= -pi:0.001:pi:
plot(x, sin(x)), grid on
>>x=2:2
x=
-2 -1 0 1 2
>>y=sqrt(x)
y=
0+1.4142i 0+1.0000i 0 1.0000 1.4142
CONCLUSION
DISCUSSION QUESTION:
1. complete the following arithmetic questions
√
(i)
√
(ii) 𝑥 = 𝑡𝑠𝑖𝑛𝑡 , where t= vector element from 1 to 10
( )
(iii) 𝑧=
[EXPERIMENT NO: 7]
>>t=0:pi/2:3*pi;
>>y=cos(t);
>>plot(t, y);
>>area(t, y);
>>grid on;
>>xlabel(‘t’);
>> ylabel(‘con(t)’);
>> title(‘plot of cos(t)’);
>>t=0:pi/2:3*pi;
>>y=tan(t);
>>plot(t, y);
>>area(t, y);
>>grid on;
>>xlabel(‘t’);
>> ylabel(‘tan(t)’);
>> title(‘plot of tan(t)’);
>>t=0:pi/2:3*pi;
>>y=sec(t);
>>plot(t, y);
>>area(t, y);
>>grid on;
>>xlabel(‘t’);
>> ylabel(‘sec(t)’);
>> title(‘plot of sec(t)’);
CONCLUSION:
From the above experiment, we have successfully generated plots of trigonometric functions
like sint, cost, tant, sect etc for a given duration.
DISCUSSION OUESTION:
1. Write a program to plot the curve for a function described by the equation y=x3+2x2-5,
where x varies from -10 to 10.
x = -10 : 0.1 : 10
y = x3+2x2-5
plot (x, y);
axis ([-10x min 10 x max 0 y min 500 y max]);