Course :Matlab Class :
Sem-1
Lesson :Basic of Matlab
Programming
By :Goutam Sanyal
Why
• Rapidly prototype an algorithm before committing the
development resources to implementing the algorithm in
another language
• It integrates computation, visualization, and programming in
an easy-to-use environment where problems and solutions
are expressed in familiar mathematical notation.
Objective
• To learn programming using MATLAB
• Graphical representation
• Application to Numerical Computation
Syllabus
• Unit I- Introduction to Programming: Components of a computer, working
with numbers, Machine code, Software hierarchy
• Unit II- Programming Environment: MATLAB Windows, A First Program,
Expressions, Constants, Variables and assignment statement, Arrays.
• Unit III- Graph Plots: Basic plotting, Built in functions, Generating
waveforms, Sound replay, load and save.
• Unit IV- Procedures and Functions: Arguments and return values, M-files,
Formatted console input-output, String handling.
• Unit V-Control Statements: Conditional statements: If, Else, Else-if,
Repetition statements: While, for loop.
• Unit VI- Manipulating Text: Writing to a text file, Reading from a text file,
Randomising and sorting a list, searching a list.
• Unit VI- Manipulating Text: Writing to a text file, Reading from a text file,
Randomising and sorting a list, searching a list.
Books
• Text Book
• Getting started with matlab :A quick introduction to scientist
and engineer , Rudra Pratap
• An Introduction to Programming and Numerical Methods in
MATLAB , S.R. Otto and J.P. Denier
• Reference Books:
• MATLAB: An Introduction with Applications, by Amos Gilat,
2nd edition, Wiley, 2004,
• C.B. Moler, Numerical Computing with MATLAB, SIAM, 2004.
• Determine the value of the expression a(b +
c(c + d))a, where a = 2, b = 3, c = −4 and d =
−3.
• MATLAB statement to evaluate the expression:
• >> a = 2; b = 3; c = -4; d = -3;
• >> a*(b+c*(c+d))*a
Example Calculate the expressions: sin 60◦ (and the
same quantity squared), exp(ln(4)), cos 45◦ −sin 45◦,
ln exp(2+cos π) and tan 30◦/(tan π/4+tan π/3).
>> x = sin(60/180*pi)
x=
0.8660
>> y = xˆ2
y=
0.7500
>> exp(log(4))
ans =
4
Manipulating Vectors and Dot Arithmetic
Program
x = -3:0.2:3; % for(x=-3;x<=3;x=x+.2) cout<<x
y = x.^3+7*x-3; % y= x3+7x-3 in c++ y=pow(x,3)+7*x-3
grid on
plot(x,y)
Thank You