saveascii.m v6.2 (Oct 2009)
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!
Cite As
Carlos Adrian Vargas Aguilera (2024). saveascii.m v6.2 (Oct 2009) (https://www.mathworks.com/matlabcentral/fileexchange/10243-saveascii-m-v6-2-oct-2009), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform Compatibility
Windows macOS LinuxCategories
Tags
Acknowledgements
Inspired: readline.m v4.0
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
Version | Published | Release Notes | |
---|---|---|---|
1.8.0.0 | Small mistake in submission name. |
||
1.7.0.0 | v6.2 Fixed small bug with parse inputs. Now creates file directory if not exist. |
||
1.6.0.0 | v6.1 Ignores empty optional inputs. Added some comments. |
||
1.5.0.0 | v6.0 Now saves cells of strings. Fixed bug with string delimiter input. |
||
1.3.0.0 | 1) Fixed SPRINTF and FPRINTF BUG with negative awful zeros!!!, like '-0.000'.
|
||
1.1.0.0 | V5.0 Rewritten help and code. Fixed minor bugs related with empty X. No more reversed outputs. No more Beginning and Ending string optional inputs allowed. No more inputs separated by commas. New overwrite optional warning. |
||
1.0.0.0 | Fixed bug when the whole column is no finite (NaN, Inf, or -Inf's). |