Putting spacing between strings

I am trying to print out something like this:
A (10 blank spaces) B (10 blank spaces) C
any ideas?

3 个评论

What are A, B, C? If they're strings, you can just do:
A = 'cat';
B = 'horse';
C = 'bird';
space = ' ';
[A,space,B,space,C]
If they're numbers, use num2str first:
A = [1,2,3,4]
B = [5,6,7,8]
C= [9]
space = ' ';
[num2str(A),space,num2str(B),space,num2str(C)]
ABC are supposed to be singular values such as 7,8,9
Then the second example there should work. I'll submit it as an answer.

请先登录,再进行评论。

回答(1 个)

jgg
jgg 2016-1-23
编辑:jgg 2016-1-23
You can do this by sending them to strings then concatenating them:
A = 1;
B = 8;
C= 9;
space = ' ';
str = [num2str(A),space,num2str(B),space,num2str(C)];
disp(str)
or you can print str to a file (it's unclear what you mean by "print out")

类别

帮助中心File Exchange 中查找有关 Low-Level File I/O 的更多信息

标签

提问:

2016-1-23

编辑:

jgg
2016-1-23

Community Treasure Hunt

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

Start Hunting!

Translated by