0
votes

I've been trying to plot the iris data points of each combination of two dimensions of the four dimension dataset which contains the sepal length, sepal width, petal length and petal width. I tried to follow the documentation written in Fuzzy C-Means Clustering for Iris Data though, I've been getting errors such as 'Error using load Unknown text on line number 1 of ASCII file iris.dat "Iris-setosa".' when I tried to type load iris.dat in the command window.

This is what I've written so far:

iris = readtable('iris.dat');
setosa = iris(1:50,:);
versicolor = iris(51:100,:);
virginica = iris(101:150,:);
obsv_n = size(iris, 1);

Characteristics = {'sepal length','sepal width','petal length','petal width'};
pairs = [1 2; 1 3; 1 4; 2 3; 2 4; 3 4];
h = figure;
for j = 1:6
    x = pairs(j, 1);
    y = pairs(j, 2);
    subplot(2,3,j);
    plot([setosa(:,x) versicolor(:,x) virginica(:,x)],[setosa(:,y) versicolor(:,y) virginica(:,y)], '.');
    xlabel(Characteristics{x});
    ylabel(Characteristics{y});
end

The only issue I have, is the line of the plot command which gives me 'Error using askisi1_5 (line 14) Duplicate table variable name: 'Var1'.'

1

1 Answers

0
votes

While I don't have the Fuzzy Logic Toolbox, I do have the Statistics & ML Toolbox, which provides a file called 'fisheriris.csv' that can be opened with readtable(). I suspect all you need to do in your case is to invoke table2array() before concatenating columns with the same variable name from different table arrays (i.e. before doing stuff like [setosa(...,n) versicolor(...,n) ...]):

iris = readtable('fisheriris.csv');
setosa = iris(1:50,:);
versicolor = iris(51:100,:);
virginica = iris(101:150,:);

Characteristics = {'sepal length','sepal width','petal length','petal width'};
setosa = table2array(setosa(:,1:end-1));
versicolor = table2array(versicolor(:,1:end-1));
virginica = table2array(virginica(:,1:end-1));

pairs = [1 2; 1 3; 1 4; 2 3; 2 4; 3 4];
h = figure;
for j = 1:6
    x = pairs(j, 1);
    y = pairs(j, 2);
    subplot(2,3,j);
    plot([setosa(:,x) versicolor(:,x) virginica(:,x)], [setosa(:,y) versicolor(:,y) virginica(:,y)], '.');
    xlabel(Characteristics{x});
    ylabel(Characteristics{y});
end

Result