1. 程式人生 > >Matlab讀取UCI數據集Iris中數據

Matlab讀取UCI數據集Iris中數據

ttr rcm tlab data bsp tla mat str cmp

>> [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中。

Matlab讀取UCI數據集Iris中數據