Azzera filtri
Azzera filtri

Load a dataset in matlab for knn classification

3 visualizzazioni (ultimi 30 giorni)
Mary Gh
Mary Gh il 31 Dic 2020
Risposto: Walter Roberson il 31 Dic 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 []

Risposte (1)

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

Categorie

Scopri di più su Develop Apps Using App Designer in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by