Load a dataset in matlab for knn classification
3 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
Walter Roberson
2020-12-31
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Statistics and Machine Learning Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!