How can i generate text file output for my code ?

2 views (last 30 days)
I want to generate text file as output..
eg. G0 X67 Y30 Z0 G1 X0 Y0 Z0
i have numbers (67, 30 ,0...) stored in cell i want to add characters like X,Y Z and G and store the result as text file.. Can anyone help? Thanks in advance.

Accepted Answer

David Sanchez
David Sanchez on 25 Jul 2013
To add/concatenate letters and numbers:
my_char = 'A';
my_number = 50;
my_string = strcat(my_char,num2str(my_number));
To save data to .txt file:
x = 0:.1:1;
A = [x; exp(x)];
fileID = fopen('exp.txt','w');
fprintf(fileID,'%6s %12s\n','x','exp(x)');
fprintf(fileID,'%6.2f %12.8f\n',A);
fclose(fileID);

More Answers (0)

Categories

Find more on Data Type Conversion in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!