How to display results in vertical table format

조회 수: 9 (최근 30일)
Rookie
Rookie 2015년 2월 12일
편집: per isakson 2015년 2월 12일
I'm writing a simple annual compound interest problem, the results are being displayed horizontally. How do I display it horizontally? below is the code.
% M-file to calculate ANNUAL Compounded Interest
% user specified values
% Amount of money = P
% Yield is the account total = F
% interest rate (decimal) = i
% number of years to calculate account total = n
display('Compound interest Formula')
P = input('Enter initial principal:');
i = input('Enter Interest rate as decimal (ex: 2% = 0.02 and 12% = 0.12): ');
t = input('Enter number of years to calculate total investment:');
disp(' Years Yield');
for k = 0:t;
F = P*(1 + i).^(k);
out = [k F];
fprintf('%5d %12.2f\t', out);
end

답변 (0개)

카테고리

Help CenterFile Exchange에서 Tables에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by