Doing a plot within a FOR LOOP

조회 수: 4 (최근 30일)
Phoebe
Phoebe 2014년 3월 3일
댓글: Phoebe 2014년 3월 3일
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

채택된 답변

Thomas
Thomas 2014년 3월 3일
편집: Thomas 2014년 3월 3일
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])
  댓글 수: 3
Thomas
Thomas 2014년 3월 3일
편집: Thomas 2014년 3월 3일
Please check edited answer..
Phoebe
Phoebe 2014년 3월 3일
Thank You! perfect.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by