Error message with code

7 Ansichten (letzte 30 Tage)
Emma K.
Emma K. am 10 Okt. 2020
Kommentiert: Sudhakar Shinde am 10 Okt. 2020
I am trying to write a code that plots TE waves for band structure showing allowed and forbidden bands. Below is what I have been able to come up with but it doesn't work! I am trying to tell matlab to plot a graph when the condition that m = or grater than + or -1 is met. In the work space when I run the code, m gives 1x300 which is definetely not correct! I want it to show 300X300.
Again, I get the error message "Unable to perform assignment because the size of the left side is 1-by-1 and the size of the right side is 1-by-2."
Your help would be highly appreciated.
clear all
n1=3.0; %refractive index of medium 1
n2=2.2; %refractive index of medium 2
a=0.5; %thickness of medium 1 in microns
b=0.5; %thickness of medium 2 in microns
c=300000000; %speed of light in vacuum;
Lambda= a+b; %period of the structure
M=300; N=M;
omega=linspace(1e-3,1,N); %angular frequency;
beta=linspace(1e-3,1,M);
m =[];
for j=1:N
for k=1:M
w=omega(k);
B=beta(j);
B=(w./c); %propagation constant
b1=((w./c).*n1).^2;
k1=sqrt(b1-B.^2);
b2=((w./c).*n2).^2;
k2=sqrt(b2-B.^2);
A(j,k)=exp(-1i.*k1.*a).*(cos(k2.*b)-(1i/2).*(k2./k1+k1./k2).*sin(k2.*b));
D(j,k)=exp(1i.*k1.*a).*(cos(k2.*b)+(1i/2).*(k2./k1+k1./k2).*sin(k2.*b));
m(j,k)=acos((A+D)./2); %m is a function of beta and omega
K=(1./Lambda).*m; %K is a function of beta and omega
end
end
[x,y]=meshgrid(omega,beta);
L=abs(m')>=1;
yte=y(L);
scatter(L,yte)
  4 Kommentare
Emma K.
Emma K. am 10 Okt. 2020
The graph I am trying to get is fig. 3 in “electromagnetic propagation in periodic stratified media.I General theory” by Pochi Yeh et al,1977. Thank you
Sudhakar Shinde
Sudhakar Shinde am 10 Okt. 2020
As you stated 'm' is a function of beta and omega. This 'm' variable now contains values less than or equal to 1 only and to plot on the values at last you used:
L=abs(m')>=1;
As there is no any values greater than 1 available in m variable, result is empty.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu MATLAB finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by