g = 1000;
k = 20;
no = 0;
nm = 40;
Del = -(10.^2);
Ohm = (10.^2);
gam = 0.0032;
C = sqrt((4.*(g.^2))./(k.*gam));
w = (-1500:1:1500);
xat = 1 - (1i.*(w + Del).*(2./k));
xbt = 1 - (1i.*(w - Ohm).*(2./gam));
c = (2.*1i.*C)./(sqrt(gam).*(xat.*xbt+(C.^2)));
d = (2.*xat)./(sqrt(gam).*(xat.*xbt+(C.^2)));
Sbb = (abs(c).^2).*(no+(1/2))+(abs(d).^2).*(nm+(1/2));
A = cumtrapz(w,Sbb);
LA = A(length(A));
Should one run the code above, one will find a plot with two sharp peaks. At g = 0, there will be one peak; With increasing g, there will be a gradual splitting of the peak into the eventual two as shown in the setting above (g = 100). Moreover for each g setting, I wish to find the area under the curve of Sbb versus w (hence my use of the cumtrapz() function). And given how cumtrapz() works, I made LA just to obtain the last entry of my A (area) array (which would give the correct area value) for some g value (g = 1000 in the above case). As it stands, LA has only one value given a particular g value, whereas A is an array since it is dependent on w and w is an array.
My question is of the following: I wish to plot a graph of LA vs C (C is dependent on g) with C varying over several values (and hence g varies as well). So, clearly I will have to loop over g and make an array to store all my C values. But since c and d depends on xat, xbt, and C, they will have to be included in the loop as well since my C is an array (which is fine). The difficulty comes in introducing w into the loop (so a double loop with g and w). In short, I ended up having to make a cell array to store all the values but became confused over the long run. I would appreciate any help in resolving this issue (for all I know I might be overthinking it).
Thank you very much in advance!