我有一個繪製3d功能的問題 - 當我輸入數據時,如果手動執行計算,我會得到一個線性圖形,並且這些值不會相加。我相信這個問題與使用矩陣有關。使用Octave繪製3D功能
INITIAL_VALUE=999999;
INTEREST_RATE=0.1;
MONTHLY_INTEREST_RATE=INTEREST_RATE/12;
# ranges
down_payment=0.2*INITIAL_VALUE:0.1*INITIAL_VALUE:INITIAL_VALUE;
term=180:22.5:360;
[down_paymentn, termn] = meshgrid(down_payment, term);
# functions
principal=INITIAL_VALUE - down_payment;
figure(1);
plot(principal);
grid;
title("Principal (down payment)");
xlabel("down payment $");
ylabel("principal $ (amount borrowed)");
monthly_payment = (MONTHLY_INTEREST_RATE*(INITIAL_VALUE - down_paymentn))/(1 - (1 + MONTHLY_INTEREST_RATE)^-termn);
figure(2);
mesh(down_paymentn, termn, monthly_payment);
title("monthly payment (principal(down payment))/term months");
xlabel("principal");
ylabel("term (months)");
zlabel("monthly payment");
像我說的第二個數字不像我預期的那樣積累。我如何更改我的公式以正確呈現?
謝謝您的回答 - 我會試試看,當我的倍頻已經不段錯誤... – Walter 2011-09-20 11:54:22