how do i adjust the alignment of the columns?

4 次查看(过去 30 天)
Hey all
I am very new to Matlab. I have recently submitted my assignment to my lecturer, he graded it with comments. He said that i should not hardcode on the alignment. I won't be seeing my lecturer for a while, therefore i am unable to ask him. Could anyone please enlighten me on this? I am keen to learn more.
I would like the output to appear like this
SGD USD GBP EURO
1.00 0.74 0.56 0.66
2.00 1.48 1.12 1.32
3.00 2.22 1.68 1.98
Here is what i have submitted.
clc
clear
a = [1 0.74 0.56 0.66];
b = (1:25)';
c = b * a;
fprintf(' SGD \t USD \t GBP \t EURO\n')
fprintf(' %.2f \t %.2f \t %.2f \t %.2f\n', c')

回答(1 个)

KSSV
KSSV 2019-4-18
I would suggest this:
a = [1 0.74 0.56 0.66];
b = (1:25)';
c = b * a;
T = table(c(:,1),c(:,2),c(:,3),c(:,4),'VariableNames',{'SGD', 'USD', 'GBP', 'EURO'} )
  1 个评论
Stephanie Pek Hsia Lim
I love the alignment for this format. Is there any way i can remove the T = 25x4 table and include the two decimal place for SGD?

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Data Distribution Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by