Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8039565
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T03:36:39+00:00 2026-06-05T03:36:39+00:00

I am on a project thumb recognition system on matlab. I implemented Kmean Algorithm

  • 0

I am on a project thumb recognition system on matlab. I implemented Kmean Algorithm and I got results as well. Actually now I want to plot the results like here they done. I am trying but couldn’t be able to do so. I am using the following code.

load training.mat; % loaded just to get trainingData variable

labelData = zeros(200,1);
labelData(1:100,:) = 0; 
labelData(101:200,:) = 1;

k=2;

[trainCtr, traina] = kmeans(trainingData,k);

trainingResult1=[];

for i=1:k
    trainingResult1 = [trainingResult1 sum(trainCtr(1:100)==i)];
end

trainingResult2=[];

for i=1:k
    trainingResult2 = [trainingResult2 sum(trainCtr(101:200)==i)];
end

load testing.mat; % loaded just to get testingData variable

c1 = zeros(k,1054);

c1 = traina;

cluster = zeros(200,1);

for j=1:200
    testTemp = repmat(testingData(j,1:1054),k,1);
    difference = sum((c1 - testTemp).^2, 2);

    [value index] = min(difference);
    cluster(j,1) = index;
end

testingResult1 = [];

for i=1:k
    testingResult1 = [testingResult1 sum(cluster(1:100)==i)];
end

testingResult2 = [];

for i=1:k
    testingResult2 = [testingResult2 sum(cluster(101:200)==i)];
end

in above code trainingData is matrix of 200 X 1054 in which 200 are images of thumbs and 1054 are columns. actually each image is of 25 X 42. I reshaped each image in to row matrix (1 X 1050) and 4 other (some features) columns so total of 1054 columns are in each image. Similarly testingData I made it in the similar manner as I made testingData It is also the order of 200 X 1054. Now my Problem is just to plot the results as they did in here.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T03:36:41+00:00Added an answer on June 5, 2026 at 3:36 am

    After selecting 2 features, you can just follow the example. Start a figure, use hold on, and use plot or scatter to plot the centroids and the data points. E.g.

    selectedFeatures = [42,43];
    plot(trainingData(trainCtr==1,selectedFeatures(1)),
         trainingData(trainCtr==1,selectedFeatures(2)),
         'r.','MarkerSize',12)
    

    Would plot the selected feature values of the data points in cluster 1.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on a project thumb recognition. following is code I am reading
My XML Looks like this: <?xml version=1.0 encoding=utf-8 ?> <projects> <project id=1 thumb=media/images/thumb.jpg >
I'm new to PHP and MySQL. For my project I want to make a
I'm recoding an existing project by using the CakePHP framework. Now, in my existing
I've got a Rails project which has a car model and it has multiple
I am making a C# app for a class project. I want to ensure
I'm having trouble deciding if I want a project of mine to be web-based
I am trying to include Crypto++ (http://www.cryptopp.com/) in an Android NDK project. I want
Project: http://design.vitalbmx.com/fave/news.html When I click Add to favorites button (under main pic), in Chrome
Project layout: /project_a /shared /project_b /shared /shared project_a and project_b both need to contain

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.