fprintf results into 2 columns
Ältere Kommentare anzeigen
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 Kommentare
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
am 30 Nov. 2022
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Mathematics finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!