Effacer les filtres
Effacer les filtres

How do I read a .txt file ?

1 vue (au cours des 30 derniers jours)
Add
Add le 25 Mar 2016
Modifié(e) : Stephen23 le 25 Mar 2016
Hi The .txt file is as such
Name Lon Lat
xxxx 12.111 15.1122
It continues for seven rows. How to read this file using fileID and formatspec ?? I want to read these 3 columns and write into 3 separate data arrays. Please help.

Réponse acceptée

Stephen23
Stephen23 le 25 Mar 2016
Modifié(e) : Stephen23 le 25 Mar 2016
fid = fopen('filename.txt','rt');
C = textscan(fid,'%s%f%f','headerlines',1);
fclose(fid);
name = C{1};
LatN = C{2};
LonN = C{3};

Plus de réponses (0)

Catégories

En savoir plus sur Low-Level File I/O 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