How to perform summation with double subscript notation?
    5 views (last 30 days)
  
       Show older comments
    
    Md. Golam Zakaria
 on 6 Mar 2022
  
    
    
    
    
    Commented: Star Strider
      
      
 on 6 Mar 2022
            Hello everyone, I have to perform some analysis based on the following equation, which contains summation operator with double subscript notation. 

I have written a code. Can anyone please look at it and confim whether I am wrong or right?
    alpha =0;
    for i=1:2
        for j=1:2
            alpha=alpha +(C(i)*A(j)*((((E-Eg(j)+Ep(i))^2)/(exp(Ep(i)/(k*T))-1))+(((E-Eg(j)-Ep(i))^2)/(1-exp(-Ep(i)/(k*T))))));
        end
    end
    Alpha=(alpha+(Ad*((E-Egd)^(1/2))));
0 Comments
Accepted Answer
  Star Strider
      
      
 on 6 Mar 2022
        First, provide the ‘C’ and the other missing vectors, then save ‘alpha’ as a matrix, then use the sum function to sum its elements.  
    alpha =0;
    for i=1:2
        for j=1:2
            alpha(i,j) = C(i)*A(j)*((((E-Eg(j)+Ep(i))^2)/(exp(Ep(i)/(k*T))-1)));
        end
    end
    Alpha=(sum(alpha(:))+(Ad*((E-Egd).^(1/2))))
Try that with the vectors to see if the result is as desired.  
.
4 Comments
  Star Strider
      
      
 on 6 Mar 2022
				I do not see anything wrong with it.  The easiest way to troubleshoot it is to see what the individual terms evaluate to, and then see if those are correct — 
h=4.136*10^-15;                         % Planck's Constant
k=8.617*10^-5;                          % Boltzmann's Constant
c=3*10^8;                               % speed of light
T=300;                                  % Ambient Temparature
beta=7.021*10^-4;
gamma=1108;
Eg0_1=1.1557;
Eg0_2=2.5;
Egd0=3.2;
Eg1=Eg0_1-((beta*(T^2))/(T+gamma));
Eg2=Eg0_2-((beta*(T^2))/(T+gamma));
Egd=Egd0-((beta*(T^2))/(T+gamma));
Eg=[Eg1 Eg2];
Ep=[1.827*10^-2 5.773*10^-2];
C=[5.5 4.0];
A=[3.231*10^2 7.237*10^3];
Ad=1.052*10^6;
walenength=(.2*10^-6):(.0001*10^-6):(1.2*10^-6);
num=numel(walenength);
Alpha=nan(1,num);
for t=1:(num/1000)
    lambda=walenength(t);
    E=((h*c)/lambda);
    alpha =0;
    for i=1:2
        for j=1:2
            fprintf([repmat('—',1, 20) '\nt = %4d\ti = %d\tj = %d\n'],t,i,j)
            Term_1(i,j) = (((E-Eg(j)+Ep(i))^2)./(exp(Ep(i)/(k.*T))-1))
            Term_2(i,j) = (((E-Eg(j)-Ep(i))^2)/(1-exp(-Ep(i)/(k*T))))
            alpha=alpha +(C(i)*A(j)*((((E-Eg(j)+Ep(i))^2)./(exp(Ep(i)/(k.*T))-1))+(((E-Eg(j)-Ep(i))^2)/(1-exp(-Ep(i)/(k*T))))));
        end
    end
    Alpha(t)=(alpha+(Ad*((E-Egd)^(1/2))));
end
figure
plot((walenength./10^-6),real(Alpha))
hold on
plot((walenength./10^-6),imag(Alpha))
plot((walenength./10^-6),abs(Alpha),'--')
hold off
set(gca,'YScale','log')
ylim([(10^0) (10^9)])
xlabel('Wavelength \lambda ,(\mum)')
ylabel('Absorption Coefficient, \alpha(m^{-1})')
legend('Re(\alpha(T))','Im(\alpha(T))','|\alpha(T)|', 'Location','best')
See if the intermediate values appear to be correct.  
.
More Answers (0)
See Also
Categories
				Find more on Data Distribution Plots 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!

