Effacer les filtres
Effacer les filtres

How do you print a cell matrix of different data types into a txt file

1 vue (au cours des 30 derniers jours)
me
me le 7 Nov 2015
It has 11 columns and about 7000 rows. the first row is full of char type data. after the first row the 1st, 2nd, 5th-11th are all double types. The 3rd and 4th row are char types. How would I copy this matrix into a txt file. I tried the following but apparently fprintf doesn't work with cell inputs.
output_fileName = 'gebreegziabher.txt';
fid2 =fopen(output_fileName, 'w');
fprintf(fid2, '%s\n', 'GPS Data');
fprintf(fid2, '%s' ,GPS_Data); %GPS_Data is the name of the cell matrix

Réponses (1)

dpb
dpb le 7 Nov 2015
A major hassle it is, indeed...to use fprintf you've got to write a specific formatting string for every line so in an irregular file such as this it's a real parsing nuisance.
I don't have a version which supports it but check out whether there's an output method for the new table data type that will handle mixed types more easily. Other than that, only better idea I've got is to do a conversion internally of all of the numeric files/rows to character via num2str or alternate and then can use a single '%s' format string for each row.
  2 commentaires
me
me le 7 Nov 2015
I tuned everything in the matrix into a string, but it still wont print it in to the txt file. is this not the correct format? fprintf(fid2, '%s' ,GPS_Data)
Walter Roberson
Walter Roberson le 7 Nov 2015
If GPS_Data is an array of character then
fprintf(fid2, '%s\n' ,GPS_Data.')

Connectez-vous pour commenter.

Catégories

En savoir plus sur Shifting and Sorting Matrices 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