How can i generate text file output for my code ?

1 次查看(过去 30 天)
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.

采纳的回答

David Sanchez
David Sanchez 2013-7-25
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);

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 String Parsing 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by