Load a dataset in matlab for knn classification
3 views (last 30 days)
Show older comments
Hello guys actually i want to load this dataset in matlab for executing knn classification on it but i dont know how to do so .i have tried load and readtable and ... but it didnt work then i have tried this code
```
FID=fopen('file','rt'); a=textscan(FID,''...);
```
But actually i could not find out what is text format to take data that i wanted so it was a dead end does any one can help me with this.please
This is how inside of my data file looks like []
0 Comments
Answers (1)
Walter Roberson
on 31 Dec 2020
filename = 'Atrain';
fid = fopen(filename, 'r');
all_data = {};
blocks = 0;
while true
for K = 1 : 4; L = fgetl(fid); if ~ischar(L); break; end; end
if feof(fid); break; end
nrow = sscanf(L, '# rows: %d');
blocks = blocks + 1;
all_data{blocks} = cell2mat(textscan(fid, '', nrow, 'headerlines', 1));
end
fclose(fid);
fprintf('File contained %d blocks of data\n', blocks);
0 Comments
See Also
Categories
Find more on Statistics and Machine Learning Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!