SlideShare une entreprise Scribd logo
1  sur  29
MATLAB
Syed Khalid Ahmed
 MATLAB (Matrix Laboratory) [1]
 MATLAB(matrix laboratory) is a multi-paradigm
numerical computing environment and fourth-generation
programming language.
 Developed by Math Works, MATLAB allows matrix
manipulations, plotting of functions and data,
implementation of algorithms, creation of user interfaces,
and interfacing with programs written in other
languages, including C, C++, Java and Fortran.
MATLAB
 MATLAB (Matrix Laboratory) [2]
 Although MATLAB is intended primarily for numerical
computing, an option al toolbox uses the MuPAD
symbolic engine, allowing access to symbolic computing
capabilities. An additional package, Simulink, adds
graphical multi-domain simulation and Model-Based
Design for dynamic and embedded systems.
 In 2004, MATLAB had around one million users across
industry and academia. MATLAB users come from
various backgrounds of engineering, science, and
economics. MATLAB is widely used in academic and
research institutions as well as industrial enterprises.
MATLAB
 Commands
 >>433.12*15.7
 ans=6.8000e+003
 MATLAB spits out the answer to our query conveniently
named ans.
 This is a variable or symbolic name that can be used to
represent the value later.
 >>x=5*6
 X=30
MATLAB
 Commands
 To write the multiplication ab, in MATLAB we type a*b
 For division, the quantity a÷b is typed as a/b. This type
of division is referred to as right division.
 MATLAB also allows another way to enter division,
called left division. We can enter the quantity by a
typing the slash mark used for division in the opposite
way, that is, we use a back slash instead of a forward
slash ab
MATLAB
 Commands
 Exponentiation a to the power b is entered in the
following way a ^ b
 Finally, addition and subtraction are entered in the
usual way
 a + b
 a –b
MATLAB
 Commands
 Individual matrix and vector entries can be referenced
with indices inside parentheses. For example, A(2,3)
denotes the entry in the second row, third column of
matrix A.
 A=[123;456;-179]
 A(2,3)
 Create a column vector, x, with:
 x=[321]’
 Or equivalently:
 x=[3;2;1]
MATLAB
 Commands
 The relational operators in MATLAB are:
 < less than
 > greater than
 <= less than or equal
 >= greater than or equal
 == equal
 ~= not equal
 Note that = is used in an assignment statement whereas
== is a relational operator.
MATLAB
 Commands
 Logical operators:
 Relational operators may be connected by logical
operators:
 & and
 | or
 ~ not
 && short-circuit and
 || short-circuit or
MATLAB
 Commands
 Inner product or dot product
 .* Array multiply:
 X.*Y denotes element-by-element multiplication. X and
Y must have the same dimensions unless one is a
scalar.
 * Matrix multiply:
 X*Y is the matrix product of X and Y. Any scalar (a 1-by-
1 matrix) may multiply anything. Otherwise, the number
of columns of X must equal the number of rows of Y.
MATLAB
 Commands
 /Slash or right matrix divide:
 A/B is the matrix division of B into A, which is roughly the
same as A*INV(B), except it is computed in a different
way. More precisely, A/B = (B'A')'.
 Backslash or left matrix divide:
 AB is the matrix division of A into B, which is roughly the
same as INV(A)*B, except it is computed in a different
way. If A is an N-by-N matrix and B is a column vector
with N components, or a matrix with several such
columns, then X=AB is the solution to the equation
singular
MATLAB
 Commands
 To divide Matrices, element-by-element, the following
formula is useful A./B
 A = [2 4 6 8]; B = [2 2 3 1];
 C = A./B
 % C = [1 2 2 8]
 Array left division is indicated by writing C = A.B (this
is the same as C = B./A):
 C = A.B
 % C = [1.0000 0.5000 0.5000 0.125]
MATLAB
 Commands
 fix()
 fix(X) rounds the elements of X to the nearest integers
towards zero.
 >> fix(5.5)
 ans =
 5
 >> fix(5.9)
 ans =
 5
MATLAB
 Commands
 rand()
 rand():returns an n-by-n matrix containing pseudo
random values drawn from the standard uniform
distribution on the open interval(0,1).
 >> n = rand(1,10)
 n =0.1576 0.9706 0.9572 0.4854 0.8003 0.1419
0.4218 0.9157 0.7922 0.9595
 >> n = fix(10*rand(1,10))
 n =8 9 1 9 6 0 2 5 9 9
MATLAB
 Commands
 Question: Simulate the outcomes of 1000 biased coin
tosses with p[Head] = 0.3
 Solution:
 n = 1000;
 randomNumber= rand(n,1);
 Heads = randomNumber<= 0.3;
 totalNumberOfHeads= sum(Heads);
 probabilityOfHeads= totalNumberOfHeads/n;
MATLAB
 Commands
 Plot(x,y) plot the graph between x and y.
 X and y are the vectors of same lengths.
 >>X=1:10
 >>y=11:20
 >> plot(x,y)
MATLAB
 Commands
 Two or more than two graphs plot on at same time with
hold on function
 x=-5:5
 y=x.*x
 plot(x,y)
 hold on
 a=1:5
 b=1:5
 plot(a,b)
MATLAB
K-MEANS
CLUSTERING
INTRODUCTION-
What is clustering?
 Clustering is the classification of objects into
different groups, or more precisely, the
partitioning of a data set into subsets
(clusters), so that the data in each subset
(ideally) share some common trait - often
according to some defined distance measure.
Common Distance measures:
 Distance measure will determine how the similarity of two
elements is calculated and it will influence the shape of the
clusters.
They include:
1. The Euclidean distance (also called 2-norm distance) is
given by:
2. The Manhattan distance (also called taxicab norm or 1-
norm) is given by:
K-MEANS CLUSTERING
 The k-means algorithm is an algorithm to cluster
n objects based on attributes into k partitions,
where k < n.
K-MEANS CLUSTERING
 Simply speaking k-means clustering is an
algorithm to classify or to group the objects
based on attributes/features into K number of
group.
 K is positive integer number.
 The grouping is done by minimizing the sum
of squares of distances between data and the
corresponding cluster centroid.
How the K-Mean Clustering
algorithm works?
 Step 1: Begin with a decision on the value of k =
number of clusters .
 Step 2: Put any initial partition that classifies the
data into k clusters. You may assign the
training samples randomly,or systematically
as the following:
1.Take the first k training sample as single-
element clusters
2. Assign each of the remaining (N-k) training
sample to the cluster with the nearest
centroid. After each assignment, recompute the
centroid of the gaining cluster.
 Step 3: Take each sample in sequence and
compute its distance from the centroid of
each of the clusters. If a sample is not
currently in the cluster with the closest
centroid, switch this sample to that cluster
and update the centroid of the cluster
gaining the new sample and the cluster
losing the sample.
 Step 4 . Repeat step 3 until convergence is
achieved, that is until a pass through the
training sample causes no new assignments.
Applications of K-Mean
Clustering
 It is relatively efficient and fast. It computes result
at O(tkn), where n is number of objects or points, k
is number of clusters and t is number of iterations.
 k-means clustering can be applied to machine
learning or data mining
 Used on acoustic data in speech understanding to
convert waveforms into one of k categories (known
as Vector Quantization or Image Segmentation).
 Also used for choosing color palettes on old
fashioned graphical display devices and Image
Quantization.
K-Mean Image Processing
Demo
Intro to MATLAB and K-mean algorithm
Intro to MATLAB and K-mean algorithm

Contenu connexe

Tendances

K-means Clustering Algorithm with Matlab Source code
K-means Clustering Algorithm with Matlab Source codeK-means Clustering Algorithm with Matlab Source code
K-means Clustering Algorithm with Matlab Source codegokulprasath06
 
K means clustering
K means clusteringK means clustering
K means clusteringAhmedasbasb
 
CC282 Unsupervised Learning (Clustering) Lecture 7 slides for ...
CC282 Unsupervised Learning (Clustering) Lecture 7 slides for ...CC282 Unsupervised Learning (Clustering) Lecture 7 slides for ...
CC282 Unsupervised Learning (Clustering) Lecture 7 slides for ...butest
 
K-means clustering algorithm
K-means clustering algorithmK-means clustering algorithm
K-means clustering algorithmVinit Dantkale
 
K mean-clustering algorithm
K mean-clustering algorithmK mean-clustering algorithm
K mean-clustering algorithmparry prabhu
 
Cluster analysis using k-means method in R
Cluster analysis using k-means method in RCluster analysis using k-means method in R
Cluster analysis using k-means method in RVladimir Bakhrushin
 
K Means Clustering Algorithm | K Means Example in Python | Machine Learning A...
K Means Clustering Algorithm | K Means Example in Python | Machine Learning A...K Means Clustering Algorithm | K Means Example in Python | Machine Learning A...
K Means Clustering Algorithm | K Means Example in Python | Machine Learning A...Edureka!
 
K Means Clustering Algorithm | K Means Clustering Example | Machine Learning ...
K Means Clustering Algorithm | K Means Clustering Example | Machine Learning ...K Means Clustering Algorithm | K Means Clustering Example | Machine Learning ...
K Means Clustering Algorithm | K Means Clustering Example | Machine Learning ...Simplilearn
 
Customer Segmentation using Clustering
Customer Segmentation using ClusteringCustomer Segmentation using Clustering
Customer Segmentation using ClusteringDessy Amirudin
 
K means clustering algorithm
K means clustering algorithmK means clustering algorithm
K means clustering algorithmDarshak Mehta
 
An improvement in k mean clustering algorithm using better time and accuracy
An improvement in k mean clustering algorithm using better time and accuracyAn improvement in k mean clustering algorithm using better time and accuracy
An improvement in k mean clustering algorithm using better time and accuracyijpla
 
K means clustering
K means clusteringK means clustering
K means clusteringkeshav goyal
 
K mean-clustering
K mean-clusteringK mean-clustering
K mean-clusteringPVP College
 

Tendances (20)

K-means Clustering Algorithm with Matlab Source code
K-means Clustering Algorithm with Matlab Source codeK-means Clustering Algorithm with Matlab Source code
K-means Clustering Algorithm with Matlab Source code
 
K means clustering
K means clusteringK means clustering
K means clustering
 
K-Means manual work
K-Means manual workK-Means manual work
K-Means manual work
 
CC282 Unsupervised Learning (Clustering) Lecture 7 slides for ...
CC282 Unsupervised Learning (Clustering) Lecture 7 slides for ...CC282 Unsupervised Learning (Clustering) Lecture 7 slides for ...
CC282 Unsupervised Learning (Clustering) Lecture 7 slides for ...
 
K-means clustering algorithm
K-means clustering algorithmK-means clustering algorithm
K-means clustering algorithm
 
K means
K meansK means
K means
 
K mean-clustering algorithm
K mean-clustering algorithmK mean-clustering algorithm
K mean-clustering algorithm
 
Cluster analysis using k-means method in R
Cluster analysis using k-means method in RCluster analysis using k-means method in R
Cluster analysis using k-means method in R
 
K Means Clustering Algorithm | K Means Example in Python | Machine Learning A...
K Means Clustering Algorithm | K Means Example in Python | Machine Learning A...K Means Clustering Algorithm | K Means Example in Python | Machine Learning A...
K Means Clustering Algorithm | K Means Example in Python | Machine Learning A...
 
Data miningpresentation
Data miningpresentationData miningpresentation
Data miningpresentation
 
K Means Clustering Algorithm | K Means Clustering Example | Machine Learning ...
K Means Clustering Algorithm | K Means Clustering Example | Machine Learning ...K Means Clustering Algorithm | K Means Clustering Example | Machine Learning ...
K Means Clustering Algorithm | K Means Clustering Example | Machine Learning ...
 
K means clustring @jax
K means clustring @jaxK means clustring @jax
K means clustring @jax
 
Kmeans
KmeansKmeans
Kmeans
 
Customer Segmentation using Clustering
Customer Segmentation using ClusteringCustomer Segmentation using Clustering
Customer Segmentation using Clustering
 
K means clustering algorithm
K means clustering algorithmK means clustering algorithm
K means clustering algorithm
 
An improvement in k mean clustering algorithm using better time and accuracy
An improvement in k mean clustering algorithm using better time and accuracyAn improvement in k mean clustering algorithm using better time and accuracy
An improvement in k mean clustering algorithm using better time and accuracy
 
K means clustering
K means clusteringK means clustering
K means clustering
 
K mean-clustering
K mean-clusteringK mean-clustering
K mean-clustering
 
08 clustering
08 clustering08 clustering
08 clustering
 
Rough K Means - Numerical Example
Rough K Means - Numerical ExampleRough K Means - Numerical Example
Rough K Means - Numerical Example
 

En vedette

Cardiac Image Analysis based on K Means Clustering
Cardiac Image Analysis based on K Means ClusteringCardiac Image Analysis based on K Means Clustering
Cardiac Image Analysis based on K Means ClusteringNAVEEN TOKAS
 
K means and dbscan
K means and dbscanK means and dbscan
K means and dbscanYan Xu
 
A study and comparison of different image segmentation algorithms
A study and comparison of different image segmentation algorithmsA study and comparison of different image segmentation algorithms
A study and comparison of different image segmentation algorithmsManje Gowda
 
PPT on BRAIN TUMOR detection in MRI images based on IMAGE SEGMENTATION
PPT on BRAIN TUMOR detection in MRI images based on  IMAGE SEGMENTATION PPT on BRAIN TUMOR detection in MRI images based on  IMAGE SEGMENTATION
PPT on BRAIN TUMOR detection in MRI images based on IMAGE SEGMENTATION khanam22
 
Image segmentation ppt
Image segmentation pptImage segmentation ppt
Image segmentation pptGichelle Amon
 
AI and Machine Learning Demystified by Carol Smith at Midwest UX 2017
AI and Machine Learning Demystified by Carol Smith at Midwest UX 2017AI and Machine Learning Demystified by Carol Smith at Midwest UX 2017
AI and Machine Learning Demystified by Carol Smith at Midwest UX 2017Carol Smith
 

En vedette (8)

Cardiac Image Analysis based on K Means Clustering
Cardiac Image Analysis based on K Means ClusteringCardiac Image Analysis based on K Means Clustering
Cardiac Image Analysis based on K Means Clustering
 
K means and dbscan
K means and dbscanK means and dbscan
K means and dbscan
 
A study and comparison of different image segmentation algorithms
A study and comparison of different image segmentation algorithmsA study and comparison of different image segmentation algorithms
A study and comparison of different image segmentation algorithms
 
PPT on BRAIN TUMOR detection in MRI images based on IMAGE SEGMENTATION
PPT on BRAIN TUMOR detection in MRI images based on  IMAGE SEGMENTATION PPT on BRAIN TUMOR detection in MRI images based on  IMAGE SEGMENTATION
PPT on BRAIN TUMOR detection in MRI images based on IMAGE SEGMENTATION
 
Image segmentation ppt
Image segmentation pptImage segmentation ppt
Image segmentation ppt
 
IMAGE SEGMENTATION.
IMAGE SEGMENTATION.IMAGE SEGMENTATION.
IMAGE SEGMENTATION.
 
K means Clustering Algorithm
K means Clustering AlgorithmK means Clustering Algorithm
K means Clustering Algorithm
 
AI and Machine Learning Demystified by Carol Smith at Midwest UX 2017
AI and Machine Learning Demystified by Carol Smith at Midwest UX 2017AI and Machine Learning Demystified by Carol Smith at Midwest UX 2017
AI and Machine Learning Demystified by Carol Smith at Midwest UX 2017
 

Similaire à Intro to MATLAB and K-mean algorithm

Digital communication lab lectures
Digital communication lab  lecturesDigital communication lab  lectures
Digital communication lab lecturesmarwaeng
 
A complete introduction on matlab and matlab's projects
A complete introduction on matlab and matlab's projectsA complete introduction on matlab and matlab's projects
A complete introduction on matlab and matlab's projectsMukesh Kumar
 
Basic MATLAB-Presentation.pptx
Basic MATLAB-Presentation.pptxBasic MATLAB-Presentation.pptx
Basic MATLAB-Presentation.pptxPremanandS3
 
Introduction to Matlab - Basic Functions
Introduction to Matlab - Basic FunctionsIntroduction to Matlab - Basic Functions
Introduction to Matlab - Basic Functionsjoellivz
 
1. Introduction.pptx
1. Introduction.pptx1. Introduction.pptx
1. Introduction.pptxSungaleliYuen
 
MATLAB-Introd.ppt
MATLAB-Introd.pptMATLAB-Introd.ppt
MATLAB-Introd.pptkebeAman
 
Dsp manual completed2
Dsp manual completed2Dsp manual completed2
Dsp manual completed2bilawalali74
 
matlab_tutorial.ppt
matlab_tutorial.pptmatlab_tutorial.ppt
matlab_tutorial.pptnaveen_setty
 
matlab_tutorial.ppt
matlab_tutorial.pptmatlab_tutorial.ppt
matlab_tutorial.pptaboma2hawi
 
Basics of matlab
Basics of matlabBasics of matlab
Basics of matlabAnil Maurya
 
MATLAB sessions Laboratory 2MAT 275 Laboratory 2Matrix .docx
MATLAB sessions Laboratory 2MAT 275 Laboratory 2Matrix .docxMATLAB sessions Laboratory 2MAT 275 Laboratory 2Matrix .docx
MATLAB sessions Laboratory 2MAT 275 Laboratory 2Matrix .docxandreecapon
 

Similaire à Intro to MATLAB and K-mean algorithm (20)

Matlab booklet
Matlab bookletMatlab booklet
Matlab booklet
 
Digital communication lab lectures
Digital communication lab  lecturesDigital communication lab  lectures
Digital communication lab lectures
 
A complete introduction on matlab and matlab's projects
A complete introduction on matlab and matlab's projectsA complete introduction on matlab and matlab's projects
A complete introduction on matlab and matlab's projects
 
Basic MATLAB-Presentation.pptx
Basic MATLAB-Presentation.pptxBasic MATLAB-Presentation.pptx
Basic MATLAB-Presentation.pptx
 
Introduction to Matlab - Basic Functions
Introduction to Matlab - Basic FunctionsIntroduction to Matlab - Basic Functions
Introduction to Matlab - Basic Functions
 
1. Introduction.pptx
1. Introduction.pptx1. Introduction.pptx
1. Introduction.pptx
 
MATLAB-Introd.ppt
MATLAB-Introd.pptMATLAB-Introd.ppt
MATLAB-Introd.ppt
 
Introduction to MATLAB
Introduction to MATLABIntroduction to MATLAB
Introduction to MATLAB
 
Dsp manual completed2
Dsp manual completed2Dsp manual completed2
Dsp manual completed2
 
EPE821_Lecture3.pptx
EPE821_Lecture3.pptxEPE821_Lecture3.pptx
EPE821_Lecture3.pptx
 
Lecture 3.pptx
Lecture 3.pptxLecture 3.pptx
Lecture 3.pptx
 
matlab_tutorial.ppt
matlab_tutorial.pptmatlab_tutorial.ppt
matlab_tutorial.ppt
 
matlab_tutorial.ppt
matlab_tutorial.pptmatlab_tutorial.ppt
matlab_tutorial.ppt
 
MatlabIntro.ppt
MatlabIntro.pptMatlabIntro.ppt
MatlabIntro.ppt
 
MatlabIntro.ppt
MatlabIntro.pptMatlabIntro.ppt
MatlabIntro.ppt
 
MatlabIntro.ppt
MatlabIntro.pptMatlabIntro.ppt
MatlabIntro.ppt
 
Matlab intro
Matlab introMatlab intro
Matlab intro
 
MatlabIntro.ppt
MatlabIntro.pptMatlabIntro.ppt
MatlabIntro.ppt
 
Basics of matlab
Basics of matlabBasics of matlab
Basics of matlab
 
MATLAB sessions Laboratory 2MAT 275 Laboratory 2Matrix .docx
MATLAB sessions Laboratory 2MAT 275 Laboratory 2Matrix .docxMATLAB sessions Laboratory 2MAT 275 Laboratory 2Matrix .docx
MATLAB sessions Laboratory 2MAT 275 Laboratory 2Matrix .docx
 

Dernier

8251 universal synchronous asynchronous receiver transmitter
8251 universal synchronous asynchronous receiver transmitter8251 universal synchronous asynchronous receiver transmitter
8251 universal synchronous asynchronous receiver transmitterShivangiSharma879191
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxk795866
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort servicejennyeacort
 
Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...121011101441
 
Vishratwadi & Ghorpadi Bridge Tender documents
Vishratwadi & Ghorpadi Bridge Tender documentsVishratwadi & Ghorpadi Bridge Tender documents
Vishratwadi & Ghorpadi Bridge Tender documentsSachinPawar510423
 
Earthing details of Electrical Substation
Earthing details of Electrical SubstationEarthing details of Electrical Substation
Earthing details of Electrical Substationstephanwindworld
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)Dr SOUNDIRARAJ N
 
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor CatchersTechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catcherssdickerson1
 
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEINFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEroselinkalist12
 
Piping Basic stress analysis by engineering
Piping Basic stress analysis by engineeringPiping Basic stress analysis by engineering
Piping Basic stress analysis by engineeringJuanCarlosMorales19600
 
welding defects observed during the welding
welding defects observed during the weldingwelding defects observed during the welding
welding defects observed during the weldingMuhammadUzairLiaqat
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfAsst.prof M.Gokilavani
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...asadnawaz62
 
Indian Dairy Industry Present Status and.ppt
Indian Dairy Industry Present Status and.pptIndian Dairy Industry Present Status and.ppt
Indian Dairy Industry Present Status and.pptMadan Karki
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girlsssuser7cb4ff
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
Solving The Right Triangles PowerPoint 2.ppt
Solving The Right Triangles PowerPoint 2.pptSolving The Right Triangles PowerPoint 2.ppt
Solving The Right Triangles PowerPoint 2.pptJasonTagapanGulla
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvLewisJB
 

Dernier (20)

8251 universal synchronous asynchronous receiver transmitter
8251 universal synchronous asynchronous receiver transmitter8251 universal synchronous asynchronous receiver transmitter
8251 universal synchronous asynchronous receiver transmitter
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptx
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
 
Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...
 
Vishratwadi & Ghorpadi Bridge Tender documents
Vishratwadi & Ghorpadi Bridge Tender documentsVishratwadi & Ghorpadi Bridge Tender documents
Vishratwadi & Ghorpadi Bridge Tender documents
 
Design and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdfDesign and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdf
 
Earthing details of Electrical Substation
Earthing details of Electrical SubstationEarthing details of Electrical Substation
Earthing details of Electrical Substation
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
 
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor CatchersTechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
 
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETEINFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
INFLUENCE OF NANOSILICA ON THE PROPERTIES OF CONCRETE
 
Piping Basic stress analysis by engineering
Piping Basic stress analysis by engineeringPiping Basic stress analysis by engineering
Piping Basic stress analysis by engineering
 
welding defects observed during the welding
welding defects observed during the weldingwelding defects observed during the welding
welding defects observed during the welding
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
Indian Dairy Industry Present Status and.ppt
Indian Dairy Industry Present Status and.pptIndian Dairy Industry Present Status and.ppt
Indian Dairy Industry Present Status and.ppt
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girls
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
Solving The Right Triangles PowerPoint 2.ppt
Solving The Right Triangles PowerPoint 2.pptSolving The Right Triangles PowerPoint 2.ppt
Solving The Right Triangles PowerPoint 2.ppt
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvv
 

Intro to MATLAB and K-mean algorithm

  • 2.  MATLAB (Matrix Laboratory) [1]  MATLAB(matrix laboratory) is a multi-paradigm numerical computing environment and fourth-generation programming language.  Developed by Math Works, MATLAB allows matrix manipulations, plotting of functions and data, implementation of algorithms, creation of user interfaces, and interfacing with programs written in other languages, including C, C++, Java and Fortran. MATLAB
  • 3.  MATLAB (Matrix Laboratory) [2]  Although MATLAB is intended primarily for numerical computing, an option al toolbox uses the MuPAD symbolic engine, allowing access to symbolic computing capabilities. An additional package, Simulink, adds graphical multi-domain simulation and Model-Based Design for dynamic and embedded systems.  In 2004, MATLAB had around one million users across industry and academia. MATLAB users come from various backgrounds of engineering, science, and economics. MATLAB is widely used in academic and research institutions as well as industrial enterprises. MATLAB
  • 4.  Commands  >>433.12*15.7  ans=6.8000e+003  MATLAB spits out the answer to our query conveniently named ans.  This is a variable or symbolic name that can be used to represent the value later.  >>x=5*6  X=30 MATLAB
  • 5.  Commands  To write the multiplication ab, in MATLAB we type a*b  For division, the quantity a÷b is typed as a/b. This type of division is referred to as right division.  MATLAB also allows another way to enter division, called left division. We can enter the quantity by a typing the slash mark used for division in the opposite way, that is, we use a back slash instead of a forward slash ab MATLAB
  • 6.  Commands  Exponentiation a to the power b is entered in the following way a ^ b  Finally, addition and subtraction are entered in the usual way  a + b  a –b MATLAB
  • 7.  Commands  Individual matrix and vector entries can be referenced with indices inside parentheses. For example, A(2,3) denotes the entry in the second row, third column of matrix A.  A=[123;456;-179]  A(2,3)  Create a column vector, x, with:  x=[321]’  Or equivalently:  x=[3;2;1] MATLAB
  • 8.  Commands  The relational operators in MATLAB are:  < less than  > greater than  <= less than or equal  >= greater than or equal  == equal  ~= not equal  Note that = is used in an assignment statement whereas == is a relational operator. MATLAB
  • 9.  Commands  Logical operators:  Relational operators may be connected by logical operators:  & and  | or  ~ not  && short-circuit and  || short-circuit or MATLAB
  • 10.  Commands  Inner product or dot product  .* Array multiply:  X.*Y denotes element-by-element multiplication. X and Y must have the same dimensions unless one is a scalar.  * Matrix multiply:  X*Y is the matrix product of X and Y. Any scalar (a 1-by- 1 matrix) may multiply anything. Otherwise, the number of columns of X must equal the number of rows of Y. MATLAB
  • 11.  Commands  /Slash or right matrix divide:  A/B is the matrix division of B into A, which is roughly the same as A*INV(B), except it is computed in a different way. More precisely, A/B = (B'A')'.  Backslash or left matrix divide:  AB is the matrix division of A into B, which is roughly the same as INV(A)*B, except it is computed in a different way. If A is an N-by-N matrix and B is a column vector with N components, or a matrix with several such columns, then X=AB is the solution to the equation singular MATLAB
  • 12.  Commands  To divide Matrices, element-by-element, the following formula is useful A./B  A = [2 4 6 8]; B = [2 2 3 1];  C = A./B  % C = [1 2 2 8]  Array left division is indicated by writing C = A.B (this is the same as C = B./A):  C = A.B  % C = [1.0000 0.5000 0.5000 0.125] MATLAB
  • 13.  Commands  fix()  fix(X) rounds the elements of X to the nearest integers towards zero.  >> fix(5.5)  ans =  5  >> fix(5.9)  ans =  5 MATLAB
  • 14.  Commands  rand()  rand():returns an n-by-n matrix containing pseudo random values drawn from the standard uniform distribution on the open interval(0,1).  >> n = rand(1,10)  n =0.1576 0.9706 0.9572 0.4854 0.8003 0.1419 0.4218 0.9157 0.7922 0.9595  >> n = fix(10*rand(1,10))  n =8 9 1 9 6 0 2 5 9 9 MATLAB
  • 15.  Commands  Question: Simulate the outcomes of 1000 biased coin tosses with p[Head] = 0.3  Solution:  n = 1000;  randomNumber= rand(n,1);  Heads = randomNumber<= 0.3;  totalNumberOfHeads= sum(Heads);  probabilityOfHeads= totalNumberOfHeads/n; MATLAB
  • 16.  Commands  Plot(x,y) plot the graph between x and y.  X and y are the vectors of same lengths.  >>X=1:10  >>y=11:20  >> plot(x,y) MATLAB
  • 17.  Commands  Two or more than two graphs plot on at same time with hold on function  x=-5:5  y=x.*x  plot(x,y)  hold on  a=1:5  b=1:5  plot(a,b) MATLAB
  • 19. INTRODUCTION- What is clustering?  Clustering is the classification of objects into different groups, or more precisely, the partitioning of a data set into subsets (clusters), so that the data in each subset (ideally) share some common trait - often according to some defined distance measure.
  • 20. Common Distance measures:  Distance measure will determine how the similarity of two elements is calculated and it will influence the shape of the clusters. They include: 1. The Euclidean distance (also called 2-norm distance) is given by: 2. The Manhattan distance (also called taxicab norm or 1- norm) is given by:
  • 21. K-MEANS CLUSTERING  The k-means algorithm is an algorithm to cluster n objects based on attributes into k partitions, where k < n.
  • 22. K-MEANS CLUSTERING  Simply speaking k-means clustering is an algorithm to classify or to group the objects based on attributes/features into K number of group.  K is positive integer number.  The grouping is done by minimizing the sum of squares of distances between data and the corresponding cluster centroid.
  • 23. How the K-Mean Clustering algorithm works?
  • 24.  Step 1: Begin with a decision on the value of k = number of clusters .  Step 2: Put any initial partition that classifies the data into k clusters. You may assign the training samples randomly,or systematically as the following: 1.Take the first k training sample as single- element clusters 2. Assign each of the remaining (N-k) training sample to the cluster with the nearest centroid. After each assignment, recompute the centroid of the gaining cluster.
  • 25.  Step 3: Take each sample in sequence and compute its distance from the centroid of each of the clusters. If a sample is not currently in the cluster with the closest centroid, switch this sample to that cluster and update the centroid of the cluster gaining the new sample and the cluster losing the sample.  Step 4 . Repeat step 3 until convergence is achieved, that is until a pass through the training sample causes no new assignments.
  • 26. Applications of K-Mean Clustering  It is relatively efficient and fast. It computes result at O(tkn), where n is number of objects or points, k is number of clusters and t is number of iterations.  k-means clustering can be applied to machine learning or data mining  Used on acoustic data in speech understanding to convert waveforms into one of k categories (known as Vector Quantization or Image Segmentation).  Also used for choosing color palettes on old fashioned graphical display devices and Image Quantization.

Notes de l'éditeur

  1. %Image 1 k=2,5,10% k=2; A=imread(&amp;apos;pic1.jpg&amp;apos;); A=im2double(A); RGB_matrix = reshape(A,size(A,1)*size(A,2),size(A,3)); clusterPointAllocationMatrix=zeros(size(RGB_matrix ,1),1); p_centroids=zeros(k,3);%previous centroids% centroids = zeros(k,3); %pick random cluster points from matrix% for i=1:k centroids(i,:)=RGB_matrix(randi([1 size(RGB_matrix ,1)],1,1),:); end [r,c]=size(RGB_matrix); %1st column=sum of R ;2nd column=sum of G;3rd cloumn =sum of B; column 4= number of values; index number represent the group number% pointsInfo = zeros(k,4); while ~isequal(centroids,p_centroids) p_centroids=centroids; pointsInfo = zeros(k,4); for j=1:r close=inf; group=0; point1=RGB_matrix(j,:); for l=1:k point2=centroids(l,:); dist=sqrt((point1(1,1)-point2(1,1))^2 + (point1(1,2)-point2(1,2))^2 + (point1(1,3)-point2(1,3))^2); if( dist &amp;lt; close ) close=dist; group=l; end end clusterPointAllocationMatrix(j,1)=group; pointsInfo(group,1)=pointsInfo(group,1)+point1(1,1);%R% pointsInfo(group,2)=pointsInfo(group,2)+point1(1,2);%G% pointsInfo(group,3)=pointsInfo(group,3)+point1(1,3);%B% pointsInfo(group,4)=pointsInfo(group,4)+1;%number of values related to that group% end %updation of centroids% for m=1:k centroids(m,1)=double(pointsInfo(m,1)/pointsInfo(m,4)); centroids(m,2)=double(pointsInfo(m,2)/pointsInfo(m,4)); centroids(m,3)=double(pointsInfo(m,3)/pointsInfo(m,4)); end end newRGB_matrix =zeros(r,c); for o=1:r newRGB_matrix(o,:)=centroids(clusterPointAllocationMatrix(o,1),:); end B=reshape(newRGB_matrix, size(A,1), size(A,2), size(A,3)); C=im2uint8(B) imshow(C);