Rounding of a number/ text file format

4 views (last 30 days)
missC
missC on 23 Jul 2014
Commented: missC on 24 Jul 2014
Hi, i used this command to save a work space variable into text file.
save('corner.txt', 'new_bpCols', '-ASCII', '-double','-append');
and the output is like I attached, I wanted to have the exact values as in the variables which is:
What format I should use?
The workspace variable value: 19 20 38 46 64 66 101 105 122 129 148 149
Thank you

Accepted Answer

Mischa Kim
Mischa Kim on 23 Jul 2014
Edited: Mischa Kim on 23 Jul 2014
missC, you could use instead
x = 1:5;
fid = fopen('corner.txt','w');
fprintf(fid,' %d\n',x); % > %d: write integer values to text file
fclose(fid)
  2 Comments
missC
missC on 24 Jul 2014
another question. How to concatenate two variables into one text file in column wise. For example: X in one column and Y in another column. Appreciate your help x = a; y = b; fid = fopen('corners.txt','w');
%table header
fprintf(fid, 'X Y \r\n');
fprintf(fid,x,'%d %d\r\n',y);

Sign in to comment.

More Answers (0)

Categories

Find more on Cell Arrays in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!