How do I iterate through a matrix to switch around data?
Show older comments
This is what I am trying to do:
(a) Step 1: Run the following code.
load fisheriris.mat; X=meas; K=3; n=150; means=X(p(1:3),:);
What these variables are:
–X is the original data
–K is the number of groups/clusters
–n is the number of data points (number of flowers that were measured)
–p takes the original data and reorders it randomly
–means takes 3 data points and sets them to the mean about which we will define the groups
(b) Step 2: Now that your means and data are set up, use your previousfunctions to assign your data points in X to one of the K=3 groups.
(c) Step 3: Now you need to recalculate means for each group. Once you calculate the means, compute distances and reassign groups.
(Hint:sum(X(find(groups==1),:))/length(find(groups==1))will calculate the mean for group 1
(d) Step 4: In a new figure, plot group 1 as red + signs, group 2 as blue x’s and group 3 as green circles using the plot 3 command. Use view(160,50)with your plots to see the data nicely.(e) Step 5: Repeat steps 2 and 3 fifteen times then apply step 4 to see the results.
This is all I have so far, I am so stuck. Please help.
p = ...... (nothing I don't even know what to do with it)
load fisheriris.mat; X=meas; K=3; n=150; means=X(p(1:3),:);
Answers (0)
Categories
Find more on App Building in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!