how do i adjust the alignment of the columns?

5 views (last 30 days)
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')

Answers (1)

KSSV
KSSV on 18 Apr 2019
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 Comment
Stephanie Pek Hsia Lim
Stephanie Pek Hsia Lim on 18 Apr 2019
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?

Sign in to comment.

Categories

Find more on Data Distribution Plots 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!