Error using pcolor function
2 views (last 30 days)
Show older comments
Hi , I want to plot my f_E function according to thetas and rs.But pcolor doesnt work.I got ??? Error using ==> pcolor at 55 Color data input must be a matrix.
If anyone helps me , I apreciate it.Thx for your concern.
if true
clear all
format long
tic
N_cut=19;
eps0=(10^-9)/(36*pi);
mu0=4*pi*10^-7;
epsr1=56.8;
epsr2=20.9;
epsr3=41.41;
mur1=1.;
mur2=1.;
mur3=1.;
eps1=epsr1*eps0;
eps2=epsr2*eps0;
eps3=epsr3*eps0;
mu1=mur1*mu0;
mu2=mur2*mu0;
mu3=mur3*mu0;
freq=9*10^6;
omeg=2*pi*freq;
sigma1=1.10;
sigma2=0.34;
sigma3=0.87;
k1=sqrt(omeg*omeg*eps1*mu1-1i*omeg*sigma1*mu1);
k2=sqrt(omeg*omeg*eps2*mu2-1i*omeg*sigma2*mu2);
k3=sqrt(omeg*omeg*eps3*mu3-1i*omeg*sigma3*mu3);
k0=omeg*sqrt(eps0*mu0);
phi=pi/2;
R_1=0.09;
R_2=0.1;
R_3=0.15;
X=mu0/mu2;
Y=mu1/mu2;
Z=mu0/mu3;
T=mu2/mu3;
X1=k0/k2;
Y1=k1/k2;
Z1=k0/k3;
T1=k2/k3;
for n=1:N_cut
A(n)=sqrt(pi.*k0.*(R_3)/2).*besselj(n+0.5,k0.*(R_3));
B(n)=-sqrt(pi*k0*(R_3)/2)*besselj(n+1.5,k0*(R_3))+(n+1).*sqrt(pi/(2*k0*(R_3)))*besselj(n+0.5,k0*(R_3));
C(n)=sqrt(pi.*k0.*(R_3)/2).*besselh(n+0.5,2,k0.*(R_3));
D(n)=-sqrt(pi*k0*(R_3)/2)*besselh(n+1.5,2,k0*(R_3))+(n+1).*sqrt(pi/(2*k0*(R_3)))*besselh(n+0.5,2,k0*(R_3));
E(n)=sqrt(pi.*k3.*(R_3)/2).*besselh(n+0.5,1,k3.*(R_3));
F(n)=-sqrt(pi*k3*(R_3)/2)*besselh(n+1.5,1,k3*(R_3))+(n+1).*sqrt(pi/(2*k3*(R_3)))*besselh(n+0.5,1,k3*(R_3));
G(n)=sqrt(pi.*k3.*(R_3)/2).*besselh(n+0.5,2,k3.*(R_3));
H(n)=-sqrt(pi*k3*(R_3)/2).*besselh(n+1.5,2,k3*(R_3))+(n+1).*sqrt(pi/(2*k3*(R_3)))*besselh(n+0.5,2,k3*(R_3));
I(n)=(sqrt(pi*k3*((R_2)/2)).*besselh(n+0.5,1,k3.*(R_2)));
J(n)=-sqrt(pi.*k3.*((R_2)/2)).*besselh(n+1.5,1,k3.*(R_2))+(n+1).*sqrt(pi./(2.*k3.*(R_2))).*besselh(n+0.5,1,k3.*(R_2));
K(n)=sqrt(pi.*k3.*(R_2)/2).*besselh(n+0.5,2,k3.*(R_2));
L(n)=-sqrt(pi*k3*(R_2)/2)*besselh(n+1.5,2,k3*(R_2))+(n+1).*sqrt(pi/(2*k3*(R_2)))*besselh(n+0.5,2,k3*(R_2));
M(n)=sqrt(pi.*k2.*(R_2)/2).*besselh(n+0.5,1,k2.*(R_2));
N(n)=-sqrt(pi*k2*(R_2)/2)*besselh(n+1.5,1,k2*(R_2))+(n+1).*sqrt(pi/(2*k2*(R_2)))*besselh(n+0.5,1,k2*(R_2));
O(n)=sqrt(pi.*k2.*(R_2)/2).*besselh(n+0.5,2,k2.*(R_2));
P(n)=-sqrt(pi*k2*(R_2)/2)*besselh(n+1.5,2,k2*(R_2))+(n+1).*sqrt(pi/(2*k2*(R_2)))*besselh(n+0.5,2,k2*(R_2));
A1(n)=sqrt(pi.*k1.*(R_1)/2).*besselh(n+0.5,1,k1.*(R_1));
B1(n)=-sqrt(pi*k1*(R_1)/2)*besselh(n+1.5,1,k1*(R_1))+(n+1).*sqrt(pi/(2*k1*(R_1)))*besselh(n+0.5,1,k1*(R_1));
C1(n)=sqrt(pi.*k1.*(R_1)/2).*besselh(n+0.5,1,k1.*(R_1));
D1(n)=-sqrt(pi*k1*(R_1)/2)*besselh(n+1.5,2,k1*(R_1))+(n+1).*sqrt(pi/(2*k1*(R_1)))*besselh(n+0.5,2,k1*(R_1));
E1(n)=sqrt(pi.*k2.*(R_1)/2).*besselh(n+0.5,1,k2.*(R_1));
F1(n)=-sqrt(pi*k2*(R_1)/2)*besselh(n+1.5,1,k2*(R_1))+(n+1).*sqrt(pi/(2*k2*(R_1)))*besselh(n+0.5,1,k2*(R_1));
G1(n)=sqrt(pi.*k2.*(R_1)/2).*besselh(n+0.5,2,k2.*(R_1));
H1(n)=-sqrt(pi*k2*(R_1)/2)*besselh(n+1.5,2,k2*(R_1))+(n+1).*sqrt(pi/(2*k2*(R_1)))*besselh(n+0.5,2,k2*(R_1));
S(n)=(((1i)^(-n))*(2*n+1))/(n*(n+1));
R1_H(n)=sqrt((mu2*eps1)/(eps2*mu1))*((A1(n)+C1(n))/(B1(n)+D1(n)));
R1_E(n)=sqrt((mu1*eps2)/(eps1*mu2))*((A1(n)+C1(n))/(B1(n)+D1(n)));
Q(n)=-((E1(n)-R1_H(n)*F1(n))/(G1(n)-R1_H(n)*H1(n)));
R(n)=-((E1(n)-R1_E(n)*F1(n))/(G1(n)-R1_E(n)*H1(n)));
R2_H(n)=sqrt((mu3*eps2)/(eps3*mu2))*((M(n)+Q(n)*O(n))/(N(n)+Q(n)*P(n)));
R2_E(n)=sqrt((mu2*eps3)/(eps2*mu3))*((M(n)+R(n)*O(n))/(N(n)+R(n)*P(n)));
Q2(n)=-((I(n)-R2_H(n)*J(n))/(K(n)-R2_H(n)*L(n)));
R2(n)=-((I(n)-R2_E(n)*J(n))/(K(n)-R2_E(n)*L(n)));
R3_H(n)=sqrt((mu0*eps3)/(eps0*mu3))*((E(n)+Q2(n)*G(n))/(F(n)+Q2(n)*H(n)));
R3_E(n)=sqrt((mu3*eps0)/(eps3*mu0))*((E(n)+R2(n)*G(n))/(F(n)+R2(n)*H(n)));
a(n)=-S(n)*((A(n)-R3_H(n)*B(n))/(C(n)-R3_H(n)*D(n)));
b(n)=-S(n)*((A(n)-R3_E(n)*B(n))/(C(n)-R3_E(n)*D(n)));
c3(n)=((S(n)*(A(n)*Z1*H(n)-B(n)*Z*G(n))+a(n)*(Z1*C(n)*H(n)-Z*D(n)*G(n)))/(Z*Z1*(E(n)*H(n)-F(n)*G(n))));
d3(n)=(S(n)*A(n)+a(n)*C(n)-Z*E(n)*c3(n))/(Z*G(n));
c3_prime(n)=((S(n)*(A(n)*Z*H(n)-B(n)*Z1*G(n))+b(n)*(Z*C(n)*H(n)-Z1*D(n)*G(n)))/(Z*Z1*(E(n)*H(n)-F(n)*G(n))));
d3_prime(n)=(S(n)*A(n)+b(n)*C(n)-Z1*E(n)*c3_prime(n))/(Z1*G(n));
c2(n)=(c3(n)*(T*I(n)*P(n)-T1*J(n)*O(n))+d3(n)*(T*K(n)*P(n)-T1*L(n)*O(n)))/(M(n)*P(n)-N(n)*O(n));
d2(n)=(T*I(n)*c3(n)+T*K(n)*d3(n)-c2(n)*M(n))/O(n);
c2_prime(n)=(c3_prime(n)*(T1*I(n)*P(n)-T*J(n)*O(n))+d3_prime(n)*(T1*K(n)*P(n)-T*L(n)*O(n)))/(M(n)*P(n)-N(n)*O(n));
d2_prime(n)=(T1*I(n)*c3_prime(n)+T1*K(n)*d3_prime(n)-c2_prime(n)*M(n))/O(n);
c1(n)=(Y*E1(n)*c2(n)+Y*G1(n)*d2(n))/(A1(n)+C1(n));
d1(n)=(Y*E1(n)*c2(n)+Y*G1(n)*d2(n))/(A1(n)+C1(n));
c1_prime(n)=(Y1*E1(n)*c2_prime(n)+Y1*G1(n)*d2_prime(n))/(A1(n)+C1(n));
d1_prime(n)=(Y1*E1(n)*c2_prime(n)+Y1*G1(n)*d2_prime(n))/(A1(n)+C1(n));
end
ygbegin=-0.15;
ygend=0.15;
zgbegin=-0.15;
zgend=0.15;
M_d=21;
deltayg=(ygend-ygbegin)/M_d;
deltazg=(zgend-zgbegin)/M_d;
xg=0;
yg=ygbegin:deltayg:ygend;
zg=zgbegin:deltazg:zgend;
for mg=1:M_d+1,
rg(mg)=sqrt(xg^2+yg(mg)^2+zg(mg)^2);
thetag(mg)=atan(sqrt(xg^2+yg(mg)^2)/zg(mg));
end
for mg=1:M_d+1
for n=1:N_cut
L1=legendre(n,cos(thetag(mg)));
L11=legendre(n-1,cos(thetag(mg)));
L2(n,mg)=L1(2,:);
if n==1
L3(n,mg)=0.;
else
L3(n,mg)=L11(2,:);
end
L2_der(n,mg)= (1/(sin(thetag(mg)).^2))*((-n)*cos(thetag(mg)*pi/180)*L2(n,mg)+(n+1)*L3(n,mg));
V(n,mg)=L2(n,mg)/(sin(thetag(mg)));
W(n,mg)=-(L2_der(n,mg)*sin(thetag(mg)));
hank1_kur1(n)=sqrt(pi.*k1.*(rg(mg))/2).*besselh(n+0.5,1,k1.*(rg(mg)));
hank2_kur1(n)=sqrt(pi.*k1.*(rg(mg))/2).*besselh(n+0.5,2,k1.*(rg(mg)));
hank1_kur1_der(n)=-sqrt(pi*k1*(rg(mg))/2)*besselh(n+1.5,1,k1*(rg(mg)))+(n+1).*sqrt(pi/(2*k1*(rg(mg))))*besselh(n+0.5,1,k1*(rg(mg)));
hank2_kur1_der(n)=-sqrt(pi*k1*(rg(mg))/2)*besselh(n+1.5,2,k1*(rg(mg)))+(n+1).*sqrt(pi/(2*k1*(rg(mg))))*besselh(n+0.5,2,k1*(rg(mg)));
hank1_kur2(n)=sqrt(pi.*k2.*(rg(mg))/2).*besselh(n+0.5,1,k2.*(rg(mg)));
hank2_kur2(n)=sqrt(pi.*k2.*(rg(mg))/2).*besselh(n+0.5,2,k2.*(rg(mg)));
hank1_kur2_der(n)=-sqrt(pi*k2*(rg(mg))/2)*besselh(n+1.5,1,k2*(rg(mg)))+(n+1).*sqrt(pi/(2*k2*(rg(mg))))*besselh(n+0.5,1,k2*(rg(mg)));
hank2_kur2_der(n)=-sqrt(pi*k2*(rg(mg))/2)*besselh(n+1.5,2,k2*(rg(mg)))+(n+1).*sqrt(pi/(2*k2*(rg(mg))))*besselh(n+0.5,2,k2*(rg(mg)));
hank1_kur3(n)=sqrt(pi.*k3.*(rg(mg))/2).*besselh(n+0.5,1,k3.*(rg(mg)));
hank2_kur3(n)=sqrt(pi.*k3.*(rg(mg))/2).*besselh(n+0.5,2,k3.*(rg(mg)));
hank1_kur3_der(n)=-sqrt(pi*k3*(rg(mg))/2)*besselh(n+1.5,1,k3*(rg(mg)))+(n+1).*sqrt(pi/(2*k3*(rg(mg))))*besselh(n+0.5,1,k3*(rg(mg)));
hank2_kur3_der(n)=-sqrt(pi*k3*(rg(mg))/2)*besselh(n+1.5,2,k3*(rg(mg)))+(n+1).*sqrt(pi/(2*k3*(rg(mg))))*besselh(n+0.5,2,k3*(rg(mg)));
bessel_out(n)=sqrt(pi.*k0.*(rg(mg))/2).*besselj(n+0.5,k0.*(rg(mg)));
hankel_out(n)=sqrt(pi.*k0.*(rg(mg))/2).*besselh(n+0.5,2,k0.*(rg(mg)));
bessel_out_der(n)=-sqrt(pi*k0*(rg(mg))/2)*besselj(n+1.5,k0*(rg(mg)))+(n+1).*sqrt(pi/(2*k0*(rg(mg))))*besselj(n+0.5,k0*(rg(mg)));
hankel_out_der(n)=-sqrt(pi*k0*(rg(mg))/2)*besselh(n+1.5,2,k0*(rg(mg)))+(n+1).*sqrt(pi/(2*k0*(rg(mg))))*besselh(n+0.5,2,k0*(rg(mg)));
if rg(mg)<=R_1
E(mg,n)=(sin(phi)/(k1*rg(mg)))*(((1i)*(c1(n)*hank1_kur1_der(n)+d1(n)*hank2_kur1_der(n))*V(n,mg))+((c1_prime(n)*hank1_kur1(n)+d1_prime(n)*hank2_kur1(n))*W(n,mg)));
else if R_1<rg(mg)<=R_2
E(mg,n)=(sin(phi)/(k2*rg(mg)))*(((1i)*(c2(n)*hank1_kur2_der(n)+d2(n)*hank2_kur2_der(n))*V(n,mg))+((c2_prime(n)*hank1_kur2(n)+d1_prime(n)*hank2_kur2(n))*W(n,mg)));
else if R_2<rg(mg)<=R_3
E(mg,n)=(sin(phi)/(k3*rg(mg)))*(((1i)*(c3(n)*hank1_kur3_der(n)+d3(n)*hank2_kur3_der(n))*V(n,mg))+((c3_prime(n)*hank1_kur3(n)+d3_prime(n)*hank2_kur3(n))*W(n,mg)));
else
E(mg,n)=(-sin(phi)/(k0*rg(mg)))*(((S(n)*bessel_out(n)+b(n)*hankel_out(n))*(-W(n,mg)))-((1i)*((S(n)*bessel_out_der(n)+a(n)*hankel_out_der(n))*...
V(n,mg))));
end
end
end
end
end
f_E=sum(E(mg,n),2);
figure
pcolor(abs(E(mg,n)))
hold
end
0 Comments
Accepted Answer
Walter Roberson
on 3 May 2013
Your line
pcolor(abs(E(mg,n)))
is after your nested "for" loops, so mg and n will each have their final values from the loop, the scalars M_d+1 and N_cut respectively. So E(mg,n) is a scalar, and abs(E(mg,n)) remains a scalar. You are trying to pcolor() a scalar value, which is not allowed.
You probably want
pcolar(abs(E))
More Answers (0)
See Also
Categories
Find more on Annotations 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!