How to use (two) vectors as variables in a compounding interest equation, so that the equation's results can be plotted on a 2D plane?

1 view (last 30 days)
I would like to explore the effect of changing the value of two certain variables in an equation for compounding interest. To make that exploration easier, I would like to assign vectors to those (two) variables, so that I can plot the result of the compounding interest equation on a 2D plane, and 'see' the effects of changing the two axis-variables.
Below is the code that I'm using and the error message that I receive. As you can see, A and I are the vectors, and the other variables are given constant values. It seems that I have a problem with the dimensions of the vector located in the exponent?
Thanks for any help!
A = 20:1:65;
I = 0:1000:250000;
Y = 65-A;
P = 0;
IR = 0.05;
CF = 1;
YOR = 30;
ETR = zeros(46,length(I));
ETR(I>=1000 & I<15000) = 0;
ETR(I>=15000 & I<25000) = 0.15;
ETR(I>=25000 & I<100000) = 0.25;
ETR(I>=100000 & I<=250000) = 0.35;
ACI = zeros(1,length(A));
ACI(A>=20 & A< 50) = 5500;
ACI(A>=50 & A<=65) = 6500;
ACD = zeros(251,length(A));
ACD(A>=20 & A< 50) = 5500;
ACD(A>=50 & A<=65) = 6500;
[A,I] = meshgrid(A,I);
EVC_IRA = ACI.*(((1+(IR/CF)).^(CF.*Y)-1)/(IR/CF));
EVD_IRA = ACD.*ETR.*(((1+(IR/CF)).^(CF.*Y)-1)/(IR/CF));
Error: Error using .* Matrix dimensions must agree.
  1 Comment
per isakson
per isakson on 7 Sep 2015
Edited: per isakson on 7 Sep 2015
Hint:
>> z = (((1+(IR/CF)).^(CF.*Y)-1)/(IR/CF));
>> whos z ACD ETR
Name Size Bytes Class Attributes
ACD 251x46 92368 double
ETR 46x251 92368 double
z 1x46 368 double
ACD.*ETR &nbsp will throw an error

Sign in to comment.

Answers (0)

Categories

Find more on Printing and Saving 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!