Trapz error (ORDER contains an invalid permutation index)
Show older comments
clear
C1 = linspace(0,1e+04,3000);
k1 = 1;
k2 = 0;
n1 = 0;
n2 = 0;
nm = 0;
D = 0;
O = 0;
gam = 1e-04.*k1;
alph = 0;
w = linspace(-5,5,3000);
for ii=1:length(C1)
for jj=1:length(w)
TA = (w(jj)+D)./(k1./2);
TB = (w(jj)-O)./(gam/2);
xa = 1-1i*TA;
xb = 1-1i*TB;
C = (2.*1i.*sqrt(C1(ii)))./(sqrt(gam).*((xa.*xb)+C1(ii)));
D = (2.*xa)./(sqrt(gam).*((xa.*xb)+C1(ii)));
MC = (abs(C)).^2;
MD = (abs(D)).^2;
Sbb = 2.*pi*(MC.*(n1+0.5)+MD.*(nm+0.5));
A = trapz(w,Sbb)./(2.*pi);
AA(ii)=A;Cum
figure(1)
plot(w,Sbb)
set(gca,'FontSize',13)
xlabel('\omega')
ylabel('S_{bb}')
%ylim([0,200])
drawnow
end
end
As stated in my title, the error:ORDER contains an invalid permutation index was returned upon compiling the code. I've searched this up and found that if I put my trapz to
trapz(w,Sbb,1)
or
trapz(w,Sbb,2)
I could remedy the problem. But it appears to not work. Can anyone assist me?
Much thanks!
Accepted Answer
More Answers (0)
Categories
Find more on Numerical Integration and Differentiation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!