On looping over drawnow

5 ビュー (過去 30 日間)
Alvin
Alvin 2017 年 10 月 4 日
コメント済み: Alvin 2017 年 10 月 4 日
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.

採用された回答

the cyclist
the cyclist 2017 年 10 月 4 日
Nothing in your for loop depends on the loop variable ii, so why would you expect the plot to change?
  1 件のコメント
Alvin
Alvin 2017 年 10 月 4 日
Indeed, I am the silliest. I've managed to fix it. Thank you.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by