Issue fprint outputting an xyz matrix to a file

6 views (last 30 days)
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.

Accepted Answer

madhan ravi
madhan ravi on 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.

More Answers (0)

Categories

Find more on Characters and Strings in Help Center and File Exchange

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by