fprintf results into 2 columns
Show older comments
Hoping someone can help me with the fprintf function... I'm trying to display the results of this into 2 even columns but its taking the results and stacking them....
Looking for the Interest_p and payment variables to display in 2 even lines...
clc; clear; close all;
principal = input('Enter Principal in Dollars: ');
years = input('Enter Number of years: ');
interest=0.0025:0.0025:0.07;
interest_m=interest/12;
n=years*12;
interest_p=interest*100;
payment=principal.*interest_m.*((interest_m+1).^n)./(((1+interest_m).^n)-1);
fprintf('****************************************************\n\n')
fprintf(' MORTGAGE PAYMENT CALCULATIONS\n\n')
fprintf(' Interest Rate Monthly Payment\n')
fprintf(' %3.2f %7.2f\n',interest_p,payment)
fprintf('****************************************************')
2 Comments
Without any loop is easy with a minor modification to your code:
principal = 1000;%input('Enter Principal in Dollars: ');
years = 5;%input('Enter Number of years: ');
interest=0.0025:0.0025:0.07;
interest_m=interest/12;
n=years*12;
interest_p=interest*100;
payment=principal.*interest_m.*((interest_m+1).^n)./(((1+interest_m).^n)-1);
%fprintf('****************************************************\n\n')
%fprintf(' MORTGAGE PAYMENT CALCULATIONS\n\n')
%fprintf(' Interest Rate Monthly Payment\n')
fprintf(' %3.2f %7.2f\n',[interest_p;payment]) % changed this line only
%fprintf('****************************************************')
Braden
on 30 Nov 2022
Accepted Answer
More Answers (0)
Categories
Find more on Mathematics 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!