As a follow up, I attempted a solution below.
clear
%g = 1; %Coupling strength
k = 20; %Decay linewidth for cavity
no = 0; %input photon number for cavity
nm = 40; %input phonon number for mechanical oscillator
Del = -(10.^2); %Delta, laser detuning
Ohm = 10.^2; %Omega, natural frequency of mechanical oscillator
gam = 0.0032; %Decay linewidth for mechanical oscillator
w = (-1199:3:1200);
g = (0:1.25:999);
xat = 1 - (1i.*(w + Del).*(2./k));
xbt = 1 - (1i.*(w - Ohm).*(2./gam));
for u=1:length(g)
C = sqrt((4.*(g(u).^2))./(k.*gam)); %Cooperativity
Ca(u) = C; %C-array
c = (2.*1i.*Ca(u))./(sqrt(gam).*(xat(u).*xbt(u)+(Ca(u).^2))); %power spectrum coefficient
ca(u)= c; %c-array
d = (2.*xat(u))./(sqrt(gam).*(xat(u).*xbt(u)+(Ca(u).^2))); %power spectrum coefficient
da(u) = d; %d-array
Sbb = (abs(ca(u)).^2).*(no + 0.5)+(abs(da(u)).^2).*(nm + 0.5);
Sbba(u) = Sbb; %Sbb-array
%Qa(u) = Q;
end
A = cumtrapz(w,Sbba); %phonon population
LA = A(length(A));
%Qa(u) = Q;
figure(1)
plot(Ca,A)
set(gca,'FontSize',13)
title('\Gamma_m = 0.2, \kappa = 1, \Omega_m = -1,\Delta = 1')
xlabel('C (cooperativity)')
ylabel('n_b (phonon population)')
The code above runs but does not make an accurate plot of LA vs Ca (I'm plotting A vs Ca afterall). Nonetheless I'm encountering issues in putting my cumtrapz function into my loop. I keep getting the error that says ORDER contains an invalid permutation index whenever I try to put my A in my loop. Moreover I feel like I'm overcomplicating this with all kinds of arrays. Please help!