proper orientation & writing to text file

9 views (last 30 days)
i have a string like
sample1 = ['Software','UserName','Author'];
sample2 = ['Matlab','john','Author1'];
sample3 = ['c','wright','Author2'];
now i need to write to txt file in below format
sample output format
Software UserName Author
Matlab john Author1
c wright Author2
problem is not able to adjust whitespaces

Accepted Answer

Walter Roberson
Walter Roberson on 23 Nov 2012
sample1 = {'Software','UserName','Author'}; %NOT square brackets!
fprintf('%14s %-14s %14s\n', sample1{:});
Walter Roberson
Walter Roberson on 27 Nov 2012
Looks like all of shaz's comments are gone :(

Sign in to comment.

More Answers (0)


Find more on Environment and Settings 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!