读取UCI数据集iris.data中数据:
>> [attrib1, attrib2, attrib3, attrib4, class] = textread('data\iris.data', '%f%f%f%f%s', 'delimiter', ',');
>> attrib = [attrib1'; attrib2'; attrib3'; attrib4']';
>> a = zeros(150, 1);
>> a(strcmp(class, 'Iris-setosa')) = 1;
>> a(strcmp(class, 'Iris-versicolor')) = 2;
>> a(strcmp(class, 'Iris-virginica')) = 3;
至此,属性值均保存到attrib中,类别值保存到数组a中。
转载于:https://www.cnblogs.com/natalie/p/4575387.html
相关资源:汇总minist数据集及matlab读取代码