please help, anybody explain me the meaning of following code
Show older comments
distance = ((vector- vec_mean).^2);
vec_mean(2:end,:)=[];
[~,label_vector] = min(distance,[],2);
% i=1:no_of_cluster;
for i=1:no_of_cluster
index=(label_vector==i);
vec_mean(:,i)=sum(vector(index))/nnz(index);
end
3 Comments
This code is incomplete, contains no comments or explanations. What exactly do you expect other users here to explain?
Follow the algorithm and you will find out what it does. Try it with some values, and use some debugging tools to help see what happens to those values. Use MATLAB's help to understand how indexing, function calls and for loops work.
Adam
on 22 Sep 2014
~ in that context just means ignore that output from the function.
You need to ask more specific questions though really. If you can't understand anything at all in that code then you need to read the basic Matlab help. If you can understand most of it then ask about the specific things you do not understand.
Stephen23
on 22 Sep 2014
Based on your response, you should read MATLAB's own introduction to programming concepts . You will find explanations, examples and other interesting info to read... just navigate around using the help's contents browser on the left hand side of the window.
To help you to understand that code, start with the sections "Language Fundamentals" and "Programming Scripts and Functions".
Accepted Answer
More Answers (0)
Categories
Find more on Matrices and Arrays 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!