SlideShare a Scribd company logo
1 of 14
Download to read offline
MATLAB & IMAGE PROCESSING
Presented by
Dr. M. Venkatanarayana, cri,ksrmce,kadapa
Basic MATLABBasic MATLAB
Interactive use
>> x=2*pi
x =
>> M'
ans =
6.2832
>> M= [pi exp(pi); 0 -1]
M =
3.1416 23.1407
0 -1.0000
3.1416 0
23.1407 -1.0000
>> M(:)
ans =
3.1416
0
23.1407
-1.0000
Arithmetic operations
>> v=[3;4]
v =
3
4
>> p=v.*v
>> size(v)
ans =
2 1
>> q=v*v'
p =
9
16
>> sum(p)
ans =
25
q =
9 12
12 16
>> r=v'*v
r =
25
Testing and Looping : if else and switch statements
clear all
a=4;
b=6;
if(a==4)
disp('equality');
end
clear all
a=input('enter number=');
b=input('enter number=');
c=input('choose option
add=1,sub=2,mul=3,div=4 :');
switch c
case 1
p=a+b
disp(['sum=' num2str(p)]);
clear all
disp(['sum=' num2str(p)]);
case 2
q=a-b
disp(['sub=' num2str(q)]);
case 3
r=a*b
disp(['mul=' num2str(r)]);
case 4
s=a/b
disp(['div=' num2str(s)]);
otherwise
disp('not valid');
end
clear all
a=4;
if(a>0)
disp('case one');
else
disp('case two')
end
For and While statements
clear all
for x=0:0.1:10
fprintf(1,'x is %dn',x)
end
x=1;
while(x<10)
x=x*1.1;
end
for k=1:20
fprintf(1,'k=%d, ans=%.2f n',k,k*pi);
end
Function and variables
function r=fact(n)
r=1;
for i=1:n
r=r*i;
end
Plotting & Graphing : plot(), stem(), mesh(), surf(), contour() and subplot()
clear all
x=0:pi/100:2*pi;
wave1=sin(x*10);
wave2=sin(x*10)+cos(x*14);
plot(wave1);
hold on
plot(wave2);
hold off 0
0.5
1
1.5
2
hold off
figure
plot(x,wave1,'-',x,wave2,':');
legend('wave1','wave2');
title('data waveforms')
xlabel('time')
ylabel('Amplitude')
0 50 100 150 200 250
-2
-1.5
-1
-0.5
0
Legend , axis and gca commands
0.5
1
1.5
2
Amplitude data waveforms
wave1
wave2
0 1 2 3 4 5 6 7
-2
-1.5
-1
-0.5
0
time
Amplitude
Loading and Saving data
M=rand(4,2);
F=fopen('mydata.dat','w');
fprintf(F,'%0.2fn', M);
fclose(F);
F=fopen('mydata.dat','r');
data=fscanf(F,'%f');
fclose(F);
Multidimensional arrays: Concatenate
a=[0 1;2 3];
b=[4 5;6 7];
c=[8 9;10 11];
md1=cat(1,a,b,c)
size(md1)
ndims(md1)
md2=cat(2,a,b,c)
size(md2)size(md2)
ndims(md2)
md3=cat(3,a,b,c)
size(md3)
ndims(md3)
Effective matlab coding : using reserved memory space using zeros command
clear all
N=16384;
tstart=cputime;
for k=1:N
x(k)=k;
y(k)=N-k+1;
end
clear all
N=16384;
tstart=cputime;
x=zeros(N,1);
y=zeros(N,1);
z=zeros(N,1);
for k=1:N
x(k)=k;end
for k=1:N
z(k)=x(k)+y(k);
end
tstop=cputime;
fprintf(1,'Time using loops = % .3f n', ...
tstop-tstart);
x(k)=k;
y(k)=N-k+1;
end
for k=1:N
z(k)=x(k)+y(k);
end
tstop=cputime;
fprintf(1,'Using preallocation = % .3f n', ...
tstop-tstart);
Vectorization is most effective way writing matlab code
clear all
N=16384;
tstart=cputime;
k=1:N;
x=k;
y=N-k+1;
z=x+y;
tstop=cputime;tstop=cputime;
fprintf(1,'Using vectorization = % .3f n', ...
tstop-tstart);
Thank youThank you

More Related Content

What's hot

Jacobi iteration method
Jacobi iteration methodJacobi iteration method
Jacobi iteration methodMONIRUL ISLAM
 
MATLAB - Aplication of Arrays and Matrices in Electrical Systems
MATLAB - Aplication of Arrays and Matrices in Electrical SystemsMATLAB - Aplication of Arrays and Matrices in Electrical Systems
MATLAB - Aplication of Arrays and Matrices in Electrical SystemsShameer Ahmed Koya
 
Gaussian Elimination Method
Gaussian Elimination MethodGaussian Elimination Method
Gaussian Elimination MethodAndi Firdaus
 
Data Approximation in Mathematical Modelling Regression Analysis and Curve Fi...
Data Approximation in Mathematical Modelling Regression Analysis and Curve Fi...Data Approximation in Mathematical Modelling Regression Analysis and Curve Fi...
Data Approximation in Mathematical Modelling Regression Analysis and Curve Fi...Dr.Summiya Parveen
 
2021 preTEST5A Final Review Packet!
2021 preTEST5A Final Review Packet!2021 preTEST5A Final Review Packet!
2021 preTEST5A Final Review Packet!A Jorge Garcia
 
2021 preTEST4A Vector Calculus
2021 preTEST4A Vector Calculus2021 preTEST4A Vector Calculus
2021 preTEST4A Vector CalculusA Jorge Garcia
 
case study of curve fitting
case study of curve fittingcase study of curve fitting
case study of curve fittingAdarsh Patel
 
Applications Section 1.3
Applications   Section 1.3Applications   Section 1.3
Applications Section 1.3mobart02
 
NUMERICAL INTEGRATION : ERROR FORMULA, GAUSSIAN QUADRATURE FORMULA
NUMERICAL INTEGRATION : ERROR FORMULA, GAUSSIAN QUADRATURE FORMULANUMERICAL INTEGRATION : ERROR FORMULA, GAUSSIAN QUADRATURE FORMULA
NUMERICAL INTEGRATION : ERROR FORMULA, GAUSSIAN QUADRATURE FORMULAKHORASIYA DEVANSU
 
Gauss Quadrature Formula
Gauss Quadrature FormulaGauss Quadrature Formula
Gauss Quadrature FormulaMaitree Patel
 
Performing Iterations in EES
Performing Iterations in EESPerforming Iterations in EES
Performing Iterations in EESNaveed Rehman
 
Math for anomaly detection
Math for anomaly detectionMath for anomaly detection
Math for anomaly detectionMenglinLiu1
 
Gaussian Quadrature Formula
Gaussian Quadrature FormulaGaussian Quadrature Formula
Gaussian Quadrature FormulaDhaval Shukla
 
preTEST3A Double Integrals Solved
preTEST3A Double Integrals SolvedpreTEST3A Double Integrals Solved
preTEST3A Double Integrals SolvedA Jorge Garcia
 
Method of least square
Method of least squareMethod of least square
Method of least squareSomya Bagai
 
Applied Numerical Methods Curve Fitting: Least Squares Regression, Interpolation
Applied Numerical Methods Curve Fitting: Least Squares Regression, InterpolationApplied Numerical Methods Curve Fitting: Least Squares Regression, Interpolation
Applied Numerical Methods Curve Fitting: Least Squares Regression, InterpolationBrian Erandio
 

What's hot (19)

Jacobi iteration method
Jacobi iteration methodJacobi iteration method
Jacobi iteration method
 
Curve fitting
Curve fitting Curve fitting
Curve fitting
 
MATLAB - Aplication of Arrays and Matrices in Electrical Systems
MATLAB - Aplication of Arrays and Matrices in Electrical SystemsMATLAB - Aplication of Arrays and Matrices in Electrical Systems
MATLAB - Aplication of Arrays and Matrices in Electrical Systems
 
Gaussian Elimination Method
Gaussian Elimination MethodGaussian Elimination Method
Gaussian Elimination Method
 
Data Approximation in Mathematical Modelling Regression Analysis and Curve Fi...
Data Approximation in Mathematical Modelling Regression Analysis and Curve Fi...Data Approximation in Mathematical Modelling Regression Analysis and Curve Fi...
Data Approximation in Mathematical Modelling Regression Analysis and Curve Fi...
 
2021 preTEST5A Final Review Packet!
2021 preTEST5A Final Review Packet!2021 preTEST5A Final Review Packet!
2021 preTEST5A Final Review Packet!
 
2021 preTEST4A Vector Calculus
2021 preTEST4A Vector Calculus2021 preTEST4A Vector Calculus
2021 preTEST4A Vector Calculus
 
case study of curve fitting
case study of curve fittingcase study of curve fitting
case study of curve fitting
 
Applications Section 1.3
Applications   Section 1.3Applications   Section 1.3
Applications Section 1.3
 
Curve Fitting
Curve FittingCurve Fitting
Curve Fitting
 
NUMERICAL INTEGRATION : ERROR FORMULA, GAUSSIAN QUADRATURE FORMULA
NUMERICAL INTEGRATION : ERROR FORMULA, GAUSSIAN QUADRATURE FORMULANUMERICAL INTEGRATION : ERROR FORMULA, GAUSSIAN QUADRATURE FORMULA
NUMERICAL INTEGRATION : ERROR FORMULA, GAUSSIAN QUADRATURE FORMULA
 
Gauss Quadrature Formula
Gauss Quadrature FormulaGauss Quadrature Formula
Gauss Quadrature Formula
 
Performing Iterations in EES
Performing Iterations in EESPerforming Iterations in EES
Performing Iterations in EES
 
Math for anomaly detection
Math for anomaly detectionMath for anomaly detection
Math for anomaly detection
 
Gaussian Quadrature Formula
Gaussian Quadrature FormulaGaussian Quadrature Formula
Gaussian Quadrature Formula
 
preTEST3A Double Integrals Solved
preTEST3A Double Integrals SolvedpreTEST3A Double Integrals Solved
preTEST3A Double Integrals Solved
 
Method of least square
Method of least squareMethod of least square
Method of least square
 
Quadrature
QuadratureQuadrature
Quadrature
 
Applied Numerical Methods Curve Fitting: Least Squares Regression, Interpolation
Applied Numerical Methods Curve Fitting: Least Squares Regression, InterpolationApplied Numerical Methods Curve Fitting: Least Squares Regression, Interpolation
Applied Numerical Methods Curve Fitting: Least Squares Regression, Interpolation
 

Similar to Basic MATLAB Programming

curve fitting or regression analysis-1.pptx
curve fitting or regression analysis-1.pptxcurve fitting or regression analysis-1.pptx
curve fitting or regression analysis-1.pptxabelmeketa
 
Unit-2 raster scan graphics,line,circle and polygon algorithms
Unit-2 raster scan graphics,line,circle and polygon algorithmsUnit-2 raster scan graphics,line,circle and polygon algorithms
Unit-2 raster scan graphics,line,circle and polygon algorithmsAmol Gaikwad
 
No factorization,no complex methods -Simplest method to solve quadratic equa...
No factorization,no complex methods -Simplest method to solve  quadratic equa...No factorization,no complex methods -Simplest method to solve  quadratic equa...
No factorization,no complex methods -Simplest method to solve quadratic equa...FabMarks
 
Informe laboratorio n°1
Informe laboratorio n°1Informe laboratorio n°1
Informe laboratorio n°1luisescobedo38
 
Fundamentals of Image Processing & Computer Vision with MATLAB
Fundamentals of Image Processing & Computer Vision with MATLABFundamentals of Image Processing & Computer Vision with MATLAB
Fundamentals of Image Processing & Computer Vision with MATLABAli Ghanbarzadeh
 
Polynomials and Curve Fitting in MATLAB
Polynomials and Curve Fitting in MATLABPolynomials and Curve Fitting in MATLAB
Polynomials and Curve Fitting in MATLABShameer Ahmed Koya
 
“Introduction to MATLAB & SIMULINK”
“Introduction to MATLAB  & SIMULINK”“Introduction to MATLAB  & SIMULINK”
“Introduction to MATLAB & SIMULINK”Amarjeetsingh Thakur
 
Line Drawing Algorithms - Computer Graphics - Notes
Line Drawing Algorithms - Computer Graphics - NotesLine Drawing Algorithms - Computer Graphics - Notes
Line Drawing Algorithms - Computer Graphics - NotesOmprakash Chauhan
 
cgrchapter2version-1-200729063505 (1).pdf
cgrchapter2version-1-200729063505 (1).pdfcgrchapter2version-1-200729063505 (1).pdf
cgrchapter2version-1-200729063505 (1).pdfmeenasp
 
Matlab polynimials and curve fitting
Matlab polynimials and curve fittingMatlab polynimials and curve fitting
Matlab polynimials and curve fittingAmeen San
 
Matrix Manipulation in Matlab
Matrix Manipulation in MatlabMatrix Manipulation in Matlab
Matrix Manipulation in MatlabMohamed Loey
 
Introduction to matlab lecture 3 of 4
Introduction to matlab lecture 3 of 4Introduction to matlab lecture 3 of 4
Introduction to matlab lecture 3 of 4Randa Elanwar
 
INTRODUCTION TO MATLAB presentation.pptx
INTRODUCTION TO MATLAB presentation.pptxINTRODUCTION TO MATLAB presentation.pptx
INTRODUCTION TO MATLAB presentation.pptxDevaraj Chilakala
 
An Introduction to MATLAB for beginners
An Introduction to MATLAB for beginnersAn Introduction to MATLAB for beginners
An Introduction to MATLAB for beginnersMurshida ck
 
College algebra in context 5th edition harshbarger solutions manual
College algebra in context 5th edition harshbarger solutions manualCollege algebra in context 5th edition harshbarger solutions manual
College algebra in context 5th edition harshbarger solutions manualAnnuzzi19
 
4-Corner Rational Distance Problems
4-Corner Rational Distance Problems4-Corner Rational Distance Problems
4-Corner Rational Distance ProblemsSara Alvarez
 

Similar to Basic MATLAB Programming (20)

Matlab
MatlabMatlab
Matlab
 
curve fitting or regression analysis-1.pptx
curve fitting or regression analysis-1.pptxcurve fitting or regression analysis-1.pptx
curve fitting or regression analysis-1.pptx
 
Unit-2 raster scan graphics,line,circle and polygon algorithms
Unit-2 raster scan graphics,line,circle and polygon algorithmsUnit-2 raster scan graphics,line,circle and polygon algorithms
Unit-2 raster scan graphics,line,circle and polygon algorithms
 
No factorization,no complex methods -Simplest method to solve quadratic equa...
No factorization,no complex methods -Simplest method to solve  quadratic equa...No factorization,no complex methods -Simplest method to solve  quadratic equa...
No factorization,no complex methods -Simplest method to solve quadratic equa...
 
Informe laboratorio n°1
Informe laboratorio n°1Informe laboratorio n°1
Informe laboratorio n°1
 
Fundamentals of Image Processing & Computer Vision with MATLAB
Fundamentals of Image Processing & Computer Vision with MATLABFundamentals of Image Processing & Computer Vision with MATLAB
Fundamentals of Image Processing & Computer Vision with MATLAB
 
Polynomials and Curve Fitting in MATLAB
Polynomials and Curve Fitting in MATLABPolynomials and Curve Fitting in MATLAB
Polynomials and Curve Fitting in MATLAB
 
“Introduction to MATLAB & SIMULINK”
“Introduction to MATLAB  & SIMULINK”“Introduction to MATLAB  & SIMULINK”
“Introduction to MATLAB & SIMULINK”
 
Line Drawing Algorithms - Computer Graphics - Notes
Line Drawing Algorithms - Computer Graphics - NotesLine Drawing Algorithms - Computer Graphics - Notes
Line Drawing Algorithms - Computer Graphics - Notes
 
cgrchapter2version-1-200729063505 (1).pdf
cgrchapter2version-1-200729063505 (1).pdfcgrchapter2version-1-200729063505 (1).pdf
cgrchapter2version-1-200729063505 (1).pdf
 
Matlab polynimials and curve fitting
Matlab polynimials and curve fittingMatlab polynimials and curve fitting
Matlab polynimials and curve fitting
 
Matrix Manipulation in Matlab
Matrix Manipulation in MatlabMatrix Manipulation in Matlab
Matrix Manipulation in Matlab
 
Introduction to matlab lecture 3 of 4
Introduction to matlab lecture 3 of 4Introduction to matlab lecture 3 of 4
Introduction to matlab lecture 3 of 4
 
INTRODUCTION TO MATLAB presentation.pptx
INTRODUCTION TO MATLAB presentation.pptxINTRODUCTION TO MATLAB presentation.pptx
INTRODUCTION TO MATLAB presentation.pptx
 
Matlab1
Matlab1Matlab1
Matlab1
 
Matdis 3.4
Matdis 3.4Matdis 3.4
Matdis 3.4
 
Prova global 2 correção
Prova global 2 correçãoProva global 2 correção
Prova global 2 correção
 
An Introduction to MATLAB for beginners
An Introduction to MATLAB for beginnersAn Introduction to MATLAB for beginners
An Introduction to MATLAB for beginners
 
College algebra in context 5th edition harshbarger solutions manual
College algebra in context 5th edition harshbarger solutions manualCollege algebra in context 5th edition harshbarger solutions manual
College algebra in context 5th edition harshbarger solutions manual
 
4-Corner Rational Distance Problems
4-Corner Rational Distance Problems4-Corner Rational Distance Problems
4-Corner Rational Distance Problems
 

Recently uploaded

Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Standamitlee9823
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . pptDineshKumar4165
 
chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringmulugeta48
 
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoorTop Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoordharasingh5698
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfJiananWang21
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756dollysharma2066
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...roncy bisnoi
 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptMsecMca
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startQuintin Balsdon
 
Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxJuliansyahHarahap1
 
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...tanu pandey
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaOmar Fathy
 

Recently uploaded (20)

Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineering
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoorTop Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
 
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Netaji Nagar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.ppt
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the start
 
Work-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptxWork-Permit-Receiver-in-Saudi-Aramco.pptx
Work-Permit-Receiver-in-Saudi-Aramco.pptx
 
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
 
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
 
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced LoadsFEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
 
Introduction to Serverless with AWS Lambda
Introduction to Serverless with AWS LambdaIntroduction to Serverless with AWS Lambda
Introduction to Serverless with AWS Lambda
 

Basic MATLAB Programming

  • 1. MATLAB & IMAGE PROCESSING Presented by Dr. M. Venkatanarayana, cri,ksrmce,kadapa
  • 3. Interactive use >> x=2*pi x = >> M' ans = 6.2832 >> M= [pi exp(pi); 0 -1] M = 3.1416 23.1407 0 -1.0000 3.1416 0 23.1407 -1.0000 >> M(:) ans = 3.1416 0 23.1407 -1.0000
  • 4. Arithmetic operations >> v=[3;4] v = 3 4 >> p=v.*v >> size(v) ans = 2 1 >> q=v*v' p = 9 16 >> sum(p) ans = 25 q = 9 12 12 16 >> r=v'*v r = 25
  • 5. Testing and Looping : if else and switch statements clear all a=4; b=6; if(a==4) disp('equality'); end clear all a=input('enter number='); b=input('enter number='); c=input('choose option add=1,sub=2,mul=3,div=4 :'); switch c case 1 p=a+b disp(['sum=' num2str(p)]); clear all disp(['sum=' num2str(p)]); case 2 q=a-b disp(['sub=' num2str(q)]); case 3 r=a*b disp(['mul=' num2str(r)]); case 4 s=a/b disp(['div=' num2str(s)]); otherwise disp('not valid'); end clear all a=4; if(a>0) disp('case one'); else disp('case two') end
  • 6. For and While statements clear all for x=0:0.1:10 fprintf(1,'x is %dn',x) end x=1; while(x<10) x=x*1.1; end for k=1:20 fprintf(1,'k=%d, ans=%.2f n',k,k*pi); end
  • 7. Function and variables function r=fact(n) r=1; for i=1:n r=r*i; end
  • 8. Plotting & Graphing : plot(), stem(), mesh(), surf(), contour() and subplot() clear all x=0:pi/100:2*pi; wave1=sin(x*10); wave2=sin(x*10)+cos(x*14); plot(wave1); hold on plot(wave2); hold off 0 0.5 1 1.5 2 hold off figure plot(x,wave1,'-',x,wave2,':'); legend('wave1','wave2'); title('data waveforms') xlabel('time') ylabel('Amplitude') 0 50 100 150 200 250 -2 -1.5 -1 -0.5 0
  • 9. Legend , axis and gca commands 0.5 1 1.5 2 Amplitude data waveforms wave1 wave2 0 1 2 3 4 5 6 7 -2 -1.5 -1 -0.5 0 time Amplitude
  • 10. Loading and Saving data M=rand(4,2); F=fopen('mydata.dat','w'); fprintf(F,'%0.2fn', M); fclose(F); F=fopen('mydata.dat','r'); data=fscanf(F,'%f'); fclose(F);
  • 11. Multidimensional arrays: Concatenate a=[0 1;2 3]; b=[4 5;6 7]; c=[8 9;10 11]; md1=cat(1,a,b,c) size(md1) ndims(md1) md2=cat(2,a,b,c) size(md2)size(md2) ndims(md2) md3=cat(3,a,b,c) size(md3) ndims(md3)
  • 12. Effective matlab coding : using reserved memory space using zeros command clear all N=16384; tstart=cputime; for k=1:N x(k)=k; y(k)=N-k+1; end clear all N=16384; tstart=cputime; x=zeros(N,1); y=zeros(N,1); z=zeros(N,1); for k=1:N x(k)=k;end for k=1:N z(k)=x(k)+y(k); end tstop=cputime; fprintf(1,'Time using loops = % .3f n', ... tstop-tstart); x(k)=k; y(k)=N-k+1; end for k=1:N z(k)=x(k)+y(k); end tstop=cputime; fprintf(1,'Using preallocation = % .3f n', ... tstop-tstart);
  • 13. Vectorization is most effective way writing matlab code clear all N=16384; tstart=cputime; k=1:N; x=k; y=N-k+1; z=x+y; tstop=cputime;tstop=cputime; fprintf(1,'Using vectorization = % .3f n', ... tstop-tstart);