SlideShare a Scribd company logo
1 of 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

More Related Content

What's hot

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
 

What's hot (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
 

Viewers also liked

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
 

Viewers also liked (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
 

Similar to 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
 

Similar to 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
 

Recently uploaded

Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxPoojaBan
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learningmisbanausheenparvam
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.eptoze12
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2RajaP95
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 
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
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxvipinkmenon1
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...srsj9000
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝soniya singh
 

Recently uploaded (20)

Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptx
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learning
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.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
 
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
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptx
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
 
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
 

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.

Editor's Notes

  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);