Professional Documents
Culture Documents
Exp No-01
Exp No-01
Theory:
What is MATLAB?
MATLAB is widely used in all areas of applied mathematics, in education and
research at universities, and in the industry. MATLAB stands for Matrix
Laboratory and the software is built up around vectors and matrices. This makes
the software particularly useful for linear algebra but MATLAB is also a great tool
for solving algebraic and differential equations and for numerical integration.
MATLAB has powerful graphic tools and can produce nice pictures in both 2D and
3D. It is also a programming language, and is one of the easiest programming
languages for writing mathematical programs. MATLAB also has some tool boxes
useful for signal processing, image processing, optimization, etc.
An m-file, or script file, is a simple text file where you can place MATLAB
commands. When the file is run, MATLAB reads the commands and executes them
exactly as it would if you had typed each command sequentially at the MATLAB
prompt. All m-file names must end with the extension.
What is MATLAB Simulink?
Simulink provides a graphical editor, customizable block libraries, and solvers for
modeling and simulating dynamic systems. It is integrated with MATLAB®,
enabling you to incorporate MATLAB algorithms into models and export
simulation results to MATLAB for further analysis.
Lab Work:
Code Output
Random 3*3 order matrices: B=
B=magic (3) 8 1 6
3 5 7
4 9 2
Colon generates number sequence: 1. K =
1. K=(7:11) 7 8 9 10 11
2. P =
2. P=(-1:1) -1 0 1
Specify step size with second colon: 3. H =
3. H= (4:2:12) 4 6 8 10 12
4. I =
4. I= (5:-2:1) 4 3 1
5. Y =
5. Y= (5:-0.7:3) 5.0000 4.3000 3.6000
Code Output
14. A=[zeros(1,3);B(3,:)] 14. A =
0 0 0
4 9 2
Mask Matrix elements: 15. S =
15. S=find(B>5) 1
6
7
8
16. T =
16. T=find(B<=2)
4
9
17. B =
17. B(find(B>5))=0 0 1 0
3 5 0
4 0 2
perators on scalars and matrices: 18. X =
18. X=[4 7;2 8]*[2 9]' 71
76
19. U=[3 7 9].*[3 7 1] 19. U =
9 49 9
Plotting:
22. x=0:15; y=0.7-0.7*cos(2*pi*x/15);
stem(x,y);
title('15-point stem graph');
Code Output
Plotting:
23. x=0:0.2:15; y=exp(x *(j-1/3));
plot(x,real(y),x,imag(y)); grid;
legend('real','imaginary');
2D Plotting:
24. x1=-10:0.2:30; y1=-
10:0.2:30;
[x,y]=meshgrid(x1,y1);
p=sqrt(x.^2+y.^2);
q=sin(p)./p; q(find(p==0))=1;
plot3(x,y,q);
grid on;
Conclusion:
In conclusion, Matlab is a important software in our daily life. It is important for an engineer or a
mathematics students. In this lab we got a big knowledge about Matlab software. It will help
my daily life work doing easier. Everyone should know about Matlab software and its
important. It is help to our life easier. Introduction to MATLAB has provided a glimpse into the
powerful capabilities of the software. We explored its versatility in handling numerical
computations, data analysis, and visualization. MATLAB's user-friendly interface, extensive
library of functions, and programming capabilities make it an invaluable tool for engineers,
scientists, and researchers. With further practice and exploration, users can harness MATLAB's
full potential for their specific needs.