Need help with this code please

I just started using MATLAB and I need help with some code that I am trying to execute. What I have to do is take the iris.data file which is in the attachment, and read the data into a matrix. The last line is a string which gives a name of a flower and depending on what name, it has to be changed to 0, 1, or 2 and update the matrix. Here is the code that I have right now but I am getting an error for line 16 that says "Index exceeds matrix dimensions."

If you can please help me to get this to work that would be great. thanks a lot.

At this line, in the first cicle, x='Iris-setosa'.I can't understand why you try to convert this string to a number.The function str2num convert a number in a string to a number:str2num('5') returns 5. For a string whitout numbers it returns an empty cell []. For this reason it can't assign the empty cell to a vector element.

Maybe you use in a wrong way the lines: strrep(x,'Iris-setosa','0') strrep(x,'Iris-versicolor','1') strrep(x,'Iris-virginica','2')what is the sense of this lines?Do you want to associate to x a different string number, '0' if x='Iris-setosa', 1 if x='Iris-versicolor, etc...?

How would I go about finding the euclidean distance between all of the points in the data set? After doing that and having the data points for the euclidean distance, how would I find the two closest points in that set?

Any suggestions will help. Thanks a lot!

There is an example of the euclidean distance equation in the code.I don't think it works correctly though. Also, what would the vectors be? 1 to 150?

Firt of all, please, explain what you mean with "distance". Here is the first 4 lines of your matrix D.What distance do you want? In your code you made only the distance between the values of the first and the 10th rows.Is this what you really want?

Make a numerical example on your matrix so that I can understand what you mean.

5.1 3.5 1.4 0.2 04.9 3 1.4 0.2 04.7 3.2 1.3 0.2 04.6 3.1 1.5 0.2 0

However your code calculate only the last distance.Remember, when you use a for cicle ad you are interested on all the values, to do in this way:

After this is executed, I will have another file that will find the two nearest points. So I believe I need two for loops so it goes over all of the data points and then compares it to all of the other data points. Also I would call the euclidean_distance function from above inside these loops somehow so that the equation is finding the nearest points of the output form the euclidean_distance function.Is this clear... sorry if I'm not good at explaining.

This code might start of like the code below but has to call the euclidean function from above some how.This code is of course only for finding the minimum of one vector so another for loop will have to be put in which would also call the euclidean function I believe

[code]

D = get_iris()

n = size(a); % variable "a" being a single vectormin = 0;

for i = 1 : 1 : n if a(i) < m m = a(i); endend[/code]

Here is the working code for "get_iris"The iris.data file should be in the attachment for the original post