Hi, i have this matlab code and was wondering if anyone could help me sort it out.

I want the formulas to calculate the NPV for each year, then to sum it. But instead the profit is calculated for year 4 only.

year=zeros(1,5)

year=[0 1 2 3 4]

tonne=145000

if year<=0
InitialInvestment=-9000000
end

if year>0
FixedOperatinCosts=-1800000
end

VariableOperatingCosts=-55*tonne
Revenue=95*tonne
Shutdowncost=-4500000

In=Revenue

if year <= 0
out=InitialInvestment
elseif 4>=year>0
Out=VariableOperatingCosts+FixedOperatinCosts
else year=4
Out=Shutdowncost+VariableOperatingCosts+FixedOpera tinCosts
end
end

Profit=zeros(1,5)
Profit=In+Out

NPV=Profit./((1.12).^year)
NPV1=sum(NPV)

Rem