Info
Questa domanda è chiusa. Riaprila per modificarla o per rispondere.
how to open this file
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hello .. I need to open file have this information
1|24|M|technician|85711
2|53|F|other|94043
3|23|M|writer|32067
4|24|M|technician|43537
5|33|F|other|15213
6|42|M|executive|98101
7|57|M|administrator|91344
8|36|M|administrator|05201
9|29|M|student|01002
10|53|M|lawyer|90703
how to open this in Matlab .I use dlmread but the format data is failed. please help me
2 Commenti
Stephen23
il 19 Feb 2016
Modificato: Stephen23
il 19 Feb 2016
Does your file really have parentheses at the beginning of the first line, and end of the last line?
It would be much simpler if you edit your question and upload the complete file, then we can try it for yourselves. Click the paperclip button, then both Choose file and Attach file buttons.
Risposte (1)
Stephen23
il 19 Feb 2016
Modificato: Stephen23
il 19 Feb 2016
You cannot use dlmread with that file because (as its documentation states quite clearly on the very first line) dlmread reads an "ASCII-delimited file of numeric data into matrix". Does the file have only numeric data? No, it does not. It is amazing how useful it is to read the MATLAB documentation.
fid = fopen('temp.txt','rt');
C = textscan(fid,'%f%f%s%s%f','Delimiter','|');
fclose(fid);
>> C{1} % 1st column
ans =
1
2
3
4
5
6
7
8
9
10
>> C{3} % 3rd column
ans =
'M'
'F'
'M'
'M'
'F'
'M'
'M'
'M'
'M'
'M'
The file I used to test my code is attached here:
1 Commento
Questa domanda è chiusa.
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!