필터 지우기
필터 지우기

Load a dataset in matlab for knn classification

조회 수: 3 (최근 30일)
Mary Gh
Mary Gh 2020년 12월 31일
답변: Walter Roberson 2020년 12월 31일
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 []

답변 (1개)

Walter Roberson
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);

카테고리

Help CenterFile Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by