Effacer les filtres
Effacer les filtres

To read a text file using matlab

3 vues (au cours des 30 derniers jours)
punith
punith le 6 Mar 2012
hi, this is a simple question
v='C:\Users\punith\Desktop\1.txt';% path
how to read text file using v

Réponse acceptée

Honglei Chen
Honglei Chen le 6 Mar 2012
Use fopen to open the file and then use fscanf or fgetl to read in the content. You can also use fread. For example, the following code reads the first line of the text.
fid = fopen(v,'r');
tline = fgetl(fid);
fclose(fid)
Just to remember close the file using fclose afterwards.
doc fopen
doc fclose
doc fread
doc fscanf
doc fgetl
  1 commentaire
punith
punith le 6 Mar 2012
thank u so much Honglei Chen

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Data Import and Export dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by