On looping over drawnow

clear
C1 = 20000;
C2 = linspace(0,26,5500);
k1 = 0.5;
k2 = 5;
n1 = 0;
n2 = 0;
nm = 0;
D = -1;
O = 1;
gam = 0.01;
alph = 0;
for ii=1:length(C2)
w = linspace(-10,10,5500);
k1eff = k1.*(1+C2);
TA = w./(k1eff./2);
TB = w./(gam./2);
Y1 = (-2.*1i.*sqrt(C1))./(sqrt(gam).*((1+C2).*(1-1i.*TA).*(1-1i.*TB)+C1));
Y2 = (-2.*sqrt(C1.*C2))./(sqrt(gam).*((1+C2).*(1-1i.*TA).*(1-1i.*TB)+C1));
Y3 = (2.*(1+C2).*(1-1i.*TA))./(sqrt(gam).*((1+C2).*(1-1i.*TA).*(1-1i.*TB)+C1));
AY1 = abs(Y1).^2;
AY2 = abs(Y2).^2;
AY3 = abs(Y3).^2;
Sbb = 2*pi.*(AY1.*(n1 + 0.5) + AY2.*(n2 + 0.5) + AY3.*(nm + 0.5));
figure(1)
plot(TB,Sbb)
drawnow limitrate
%ylim([0,30])
set(gca,'FontSize',13)
xlabel('\Theta_B')
ylabel('S_{bb}')
%ylim([0,5])
end
I am trying to plot my Sbb as a function of TB for each step of the loop. Upon executing the code above however I see a curve with two peaks with different heights but the graph isn't changing over time. Much help would be appreciated. Thank you in advance.

 Accepted Answer

the cyclist
the cyclist on 4 Oct 2017

0 votes

Nothing in your for loop depends on the loop variable ii, so why would you expect the plot to change?

1 Comment

Indeed, I am the silliest. I've managed to fix it. Thank you.

Sign in to comment.

More Answers (0)

Categories

Find more on Graphics Performance in Help Center and File Exchange

Tags

Asked:

on 4 Oct 2017

Commented:

on 4 Oct 2017

Community Treasure Hunt

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

Start Hunting!