How to write a matrix into a txt file so that all variables in a columns have exactly the same starting character and length?
Show older comments
I am trying to export a matrix into a text file. The text file will later be feed into another program that requires all variables in a specific columns have the same starting location, and the same length.
How should I achieve this? Which Matlab function should I use to export the data?
Thank you.
Accepted Answer
More Answers (2)
Liqing
on 21 Apr 2011
0 votes
Fangjun Jiang
on 25 Apr 2011
0 votes
What do you mean? What exact format do you want to achieve? Please read through the document of sprintf formatting. I think it should be able to cover most if not all format.
Is this what you need?
sprintf('%010.2f\n',45,-45,26.7,126.8)
Categories
Find more on Workspace Variables and MAT Files 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!