0
votes

I'm tryting to store the text data into MATLAB but it has an error.

The data has 11 attributes and the last attributes represent the class of the data.

filepath = '/train.txt';
fileID = fopen(filepath);
C = textscan(fileID,'%s %s %s %s %s %s %s %s %s %s %s','Delimiter',',');
fclose(fileID);

N = size(C{1},1);

D = 11; %number of attributes
data = zeros(N,D);
label = zeros(N,1);


for n=1:N %1~214
    for d=1:D %1~11
        data(n,d) = C{d}{n};
    end
    label(n) = C{D}{n};
end

I get the error:

Subscripted assignment dimension mismatch.
Error in readdata (line 19)
data(n,d) = C{d}{n};

1

1 Answers

0
votes

Probaly because C{d}{n} does not contain a number or what you expect, I sugest you try debugging before the assingment to see if every C{}{} is a single number and also check if textscan is properly reading the file with the format