Doing a plot within a FOR LOOP

Phoebe

Phoebe (view profile)

님이 질문을 제출함. 3 Mar 2014
최근 활동 Phoebe

Phoebe (view profile)

님이 댓글을 추가함. 3 Mar 2014
Thomas

Thomas (view profile)

님이 답변을 채택함.
I want to plot all values of B for changing i from following code;
clear
for i = 0.04 : 0.01 : 0.06
B = -20000 + 57300*((1+i)^-20)
plot(i,B,'-ro')
axis([0 0.06 -2134 6152])
i=i+0.01;
end
I put the axis line in as the plot was showing much vaguer values? It only shows one final plot for i=0.06 so could someone help me please??
Thanks

로그인 to comment.

답변 수: 1

Thomas

님의 답변 3 Mar 2014
Thomas

Thomas (view profile)

님이 편집함. 3 Mar 2014
채택된 답변

some thing like this?
clear
for i = 0.04 : 0.01 : 0.06
B = -20000 + 57300*((1+i)^-20)
figure()
plot(i,B,'-ro','markerSize',10)
axis([0 0.06 -2140 6160])
% i=i+0.01;
end
EDIT- For all on the same plot-- no need of for loop at all
i=[0.04:0.01:0.06];
B = -20000 + 57300*((1+i).^-20)
plot(i,B,'-ro','markerSize',10,'LineWidth',1)
axis([0 0.06 -2140 6160])

Phoebe

Phoebe (view profile)

3 Mar 2014
hmm this gives me three seperate plots for each value whereas i would like a plot that shows a line with gradient joining the points for each value of i??
Thomas

3 Mar 2014