Issue fprint outputting an xyz matrix to a file

11 vues (au cours des 30 derniers jours)
Wthee
Wthee le 1 Oct 2020
Attempting to convert a txt file that has three columns and many rows of xyz coords.
I'll just paste what I have.
file1 = fopen('test.txt' , 'w');
for m = 1:size(data,1)
fprintf( 'Create vertex x %.f y %.f z %.f\n',[data(m,1);data(m,2);data(m,3)]);
end
'data' is the file I am attempting to pull data from. No output to test.txt, at the moment.

Réponse acceptée

madhan ravi
madhan ravi le 1 Oct 2020
fid = fopen('test.txt' , 'w');
fprintf(fid, 'Create vertex x %.2f y %.2f z %.2f\n',data.')
fclose(fid)
Why not simply use writematrix() or writetable(), it's much easier.

Plus de réponses (0)

Catégories

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

Produits


Version

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by