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일

0 개 추천

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개)

카테고리

도움말 센터File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

태그

질문:

2017년 10월 4일

댓글:

2017년 10월 4일

Community Treasure Hunt

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

Start Hunting!

Translated by