i1 = 0.07;      % i(0, 1)
i2 = .075;      % i(0, 2)
i3 = .065;      % i(0, 3)
i4 = 0.08;      % i(0, 4)
x1 = 1; x2 = 1; x3 = 1; 
x4 = ...  % use ... to break the instruction
    100;  % in more than one line
t1 = 1; t2 = 2; t3 = 3; t4 = 4;
V1 = x1*(1 + i1)^-t1 % present value of x1
V2 = x2*(1 + i2)^-t2 % present value of x2
V3 = x3*(1 + i3)^-t3 % present value of x3
V4 = x4*(1 + i4)^-t4 % present value of x4
D = (V1*t1 + V2*t2 + V3*t3 + V4*t4)/(V1 + V2 + V3 + V4)

% or
i = [0.07, .075, .065, 0.08]       
x = [1 1 1 100]; t = [1 2 3 4];
V = x.*(1 + i).^-t
D = sum(V.*t)/sum(V)