How do I read a file in using fopen correctly
Afficher commentaires plus anciens
I am trying to read in spectroscopic data in using fopen and place the data into the y array. The file dimensions are 69 * 22533. What am I doing incorrectly?
x = 1:5; %5
y = zeros(69,22533);
fileID = fopen('Pandora166s1_LabGSFC_20200115_L0_subset (1).txt','w');
fprintf(fileID,'%d %4.4f\n',y);
fclose(fileID);
3 commentaires
Walter Roberson
le 9 Fév 2020
That is code to write a lot of zeroes into a file, not to read from a file.
Your format hints that in your file the first column is an integer. Is that some kind of index? If so then how does it relate to the location to place the data into y?
Daniel Montgomery
le 10 Fév 2020
Walter Roberson
le 10 Fév 2020
Please show an extract of the file.
Réponse acceptée
Plus de réponses (1)
Daniel Montgomery
le 10 Fév 2020
0 votes
1 commentaire
Walter Roberson
le 10 Fév 2020
That is not a consistent number of characters per row?
What would you expect the output to be for that extract?
Catégories
En savoir plus sur Low-Level File I/O dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!