Do you still use SAVE -ASCII, DLMWRITE or DISP, NUM2STR?
With this program you can save (or display) your data with a different format and delimiters for every column, given as optional inputs in a user-friendly way (check the screenshot).
If you don't want to deal with the format (things like '%3.1f %13.4f', etc.) you can give only the precision that you want for each (or every) column (i.e. [1 4]) and the program creates the format by itself.
See this example about saving and displaying data with precision as input:
% DATA:
>> c = [ -130.145 45
>> -130.1 45.6789 ];
>> cfile = 'coord.dat';
% SAVING FILE WITH COMMENTED HEADING:
>> saveascii('% My coordinates',cfile)
>> saveascii('% [LON LAT]',cfile,'a')
>> saveascii(c, cfile, 2, 'a')
% VIEWING THE RESULT:
>> edit(cfile)
---------------------------
% My coordinates
% [LON LAT]
-130.15 45.00
-130.10 45.68
---------------------------
% LOADING DATA IGNORING HEADING:
>> c = load(cfile);
c =
-130.1500 45.0000
-130.1000 45.6800
% DISPLAYING LOADED DATA:
>> saveascii(c,1,' ') % With only 1 decimal (better than DISP)
-130.2 45.0 % and extra spaces within
-130.1 45.7
% VIEWING THE HEADING WITH readline.m
>> disp(readline(cfile))
% My coordinates
>> disp(readline(cfile,2))
% [LON LAT]
Enjoy it!
Any comments and bugs reports will be very appreciated! |