How can I read a text file and import a part of it into matlab.
Mostra commenti meno recenti
I have a text file with 13 columns and some 900 rows. But,column 9 to 12 are asterisk and 13th is again numeric.I want to import only the numerics from 1st row to 38th row and 1st column to 8th column.Please help.
1 Commento
Stephen23
il 23 Giu 2016
@Bibhu Das: please edit your question and upload the file by clicking the paperclip button.
Risposta accettata
Più risposte (1)
rocketboyjka
il 23 Giu 2016
Modificato: rocketboyjka
il 23 Giu 2016
Take a look at the the textscan() function. Something like this should work:
numRows = 38; % Or however many you want
fileID = fopen('MyFile.txt'); % Open the file
myData = textscan(fileID,'%f %f %f %f %f %f %f %f %s %s %s %s %f',numRows); % Read the specified format
fclose(fileID); % close the file
myData = myData([1:8]); % get rid of the columns you don't want
myData = cell2mat(myData); % Convert the cell array to a matrix
Categorie
Scopri di più su Large Files and Big Data in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!