Filter löschen
Filter löschen

Load a dataset in matlab for knn classification

3 Ansichten (letzte 30 Tage)
Mary Gh
Mary Gh am 31 Dez. 2020
Beantwortet: Walter Roberson am 31 Dez. 2020
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 []

Antworten (1)

Walter Roberson
Walter Roberson am 31 Dez. 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);

Kategorien

Mehr zu Develop Apps Using App Designer finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by