hello, i am having some trouble superimposing 2 graph. when i run the following script, matlab says that the vectors are not equal (i am guessing this is because one is in months while another is in years??). can someone please point out what i am doing wrong?
n = 18*12+1;
balance([1,n],1)=[2000;0];
for b1=2:n
balance(b1)=(balance(b1-1)*(1+(5.5/1200))+200);
end
for year=2:22
cost(year)= cost(year-1)+(cost(year-1)*0.08);
end
totalcost= cost(19)+cost(20)+cost(21)+cost(22);
figure(1)
x=1/12*[1:216];
y1=balance;
y2= ones(1,216)*totalcost;
plot(x,y1,'k', x,y2,'b')

 채택된 답변

Walter Roberson
Walter Roberson 2015년 11월 2일

0 개 추천

n = 18*12+1; -- is it even or odd?
x=1/12*[1:216]; -- does it have an even number of elements or an odd number of elements?

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

태그

질문:

2015년 11월 2일

답변:

2015년 11월 2일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by