How can I plot the functions in my code according to theta?
Show older comments
Here is my code.
clear all
format long
tic
N_cut=20;
eps0=(10^-9)/(36*pi);
mu0=4*pi*10^-7;
epsr1=1.;
epsr2=2.;
mur1=1.;
mur2=1.;
eps1=epsr1*eps0;
eps2=epsr2*eps0;
mu1=mur1*mu0;
mu2=mur2*mu0;
freq=299.7925*10^6;
omeg=2*pi*freq;
k=omeg*sqrt(eps1*mu1);
lambda=2*pi/k;
phi=45;
R=1.1;
for n=1:N_cut
bes_kur1(n)=sqrt(pi.*k.*R./2).*besselj(n+0.5,k.*R);
han_kur1(n)=sqrt(pi.*k.*R./2).*besselh(n+0.5,2,k.*R);
bes_kur_der1(n)=-n.*sqrt(pi.*k./(2.*R)).*besselj(n+0.5,k.*R)+k.*sqrt(pi.*k.*R./2).*besselj(n-0.5,k.*R);
han_kur_der1(n)=-n.*sqrt(pi.*k./(2.*R)).*besselh(n+0.5,2,k.*R)+k.*sqrt(pi.*k.*R/2).*besselh(n-0.5,2,k.*R);
han_kur_dd(n)=sqrt(pi.*k.*R./2).*besselh(n+2.5,2,k.*R)-sqrt(pi./(2.*k.*R)).*(2.*n+3).*besselh(n+1.5,2,k.*R)+sqrt(pi./(2.*(k.*R).^3)).*...
n.*(n+1).*besselh(n+0.5,2,k.*R);
a(n)=(1i.^(-n)).*(2.*n+1)./(n.*(n+1));
b(n)=(-a(n)).*bes_kur_der1(n)./han_kur_der1(n);
c(n)=(-a(n)).*bes_kur1(n)./han_kur1(n);
L1=legendre(n,cosd(theta));
L11=legendre(n-1,cosd(theta));
L2(n)=L1(2);
if n==1
L3(n)=0.;
else
L3(n)=L11(2);
end
L2_der(n)=(-(n+1).*L3(n)+n.*cosd(theta)).*L2(n)/sind(theta);
E_r=((-1i.*cosd(phi).*b(n).*L3(n).*(han_kur_dd(n)+han_kur1(n))));
E_theta=(cosd(phi)./(k.*R)).*((1i)*b(n)*han_kur_der1(n).*sin(theta).*L2_der(n)-c(n).*han_kur1(n)*(L3(n)./sin(theta)));
E_phi=(sin(phi))./(k.*R).*(((1i).*b(n).*han_kur_der1(n).*(L3(n)./(sin(theta))))-(c(n).*han_kur1(n).*sin(theta)).*L2_der(n));
end
F_Er=sum(E_r);
F_Etheta=sum(E_theta);
F_Ephi=sum(E_phi);
figure
plot(theta,abs(F_Er)),grid on
hold
figure
plot(theta,abs(F_Etheta)),grid on
hold
figure
plot(theta,abs(F_Ephi)),grid on
hold
3 Comments
Walter Roberson
on 9 Apr 2013
You have not defined any theta. Are you hoping to represent it abstractly, to create the other variables as a function of a symbolic theta ?
Burak
on 9 Apr 2013
Walter Roberson
on 9 Apr 2013
Hmmm, okay, but are you going to be doing anything with the formulas afterwards that you need them to be in function form? Or do you just need to be able to plot, in which case you could possibly proceed with numeric theta?
Accepted Answer
More Answers (0)
Categories
Find more on Creating and Concatenating Matrices 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!