How can I align text to be left-justified using fprintf?

32 次查看(过去 30 天)
While using fprintf I would get text that aligns at the end of the word by default. I need it to be able to align at the beginning or left hand side of the word. Thanks.

回答(1 个)

dpb
dpb 2014-4-2
>> fprintf('%10s\n','abcdef')
abcdef
>> fprintf('%-10s\n','abcdef')
abcdef
>>
doc fprintf
read up on format string in the links thereto...

类别

Help CenterFile Exchange 中查找有关 Characters and Strings 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by