How can i generate text file output for my code ?

2 Ansichten (letzte 30 Tage)
siddhesh rane
siddhesh rane am 25 Jul. 2013
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.

Akzeptierte Antwort

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

Weitere Antworten (0)

Kategorien

Mehr zu Data Type Conversion finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by