problem in plot for two function
古いコメントを表示
Hi
i want to plot two function in the same axis
i rreceive to message Escattheory(rho,phi))
Error using plot
Data must be numeric, datetime, duration, categorical, or an array convertible
to double.
function y = Escattheory(rho,phi)
%UNTITLED Summary of this function goes here
% Detailed explanation goes here
syms k
global k0
global ra
Z1=k0.*rho
Z2=k0.*ra;
scale=1;
factor1=besselh(k,2,Z1).*besselj(k,Z2)./besselh(k,2,Z2);
factor2=(-1i).^k.*cos(k.*phi);
factor=factor1.*factor2.*en(k);
y=vpa(symsum(factor,k,0,inf),3)
end
and for the second i receive the message
Unable to perform assignment because the indices on the left side are not
compatible with the size of the right side.
Error in Escat (line 15)
RR(jj)=sqrt((x-xx(jj)).^2+(y-yy(jj)).^2);
Error in mas_closett_linsolve_2_2 (line 80)
plot(rho,abs(Escat(x,y)))
function y = Escat(x,y)
%UNTITLED Summary of this function goes here
% Detailed explanation goes here
global Is
global Nc
global k0
global Z0
global a
global Is
sum=0;
for jj=1:Nc
xx(jj)=a.*cos(2.*pi.*(jj-1)./Nc);
yy(jj)=a.*sin(2*pi.*(jj-1)./Nc);
RR(jj)=sqrt((x-xx(jj)).^2+(y-yy(jj)).^2);
sum=sum-Is(jj).*k0.*Z0.*besselh(0,2,k0.*RR(jj))./4;
end
y=sum;
end
what happen ??
thank you
George
the main code is
clear all
clc
global ra
global N
global a
global f
global Is
global N
global Nc
global k0
global Z0
global ra
global a
Z0=120.*pi;
c0=3e8;
f= input('Give the freuency = ');
%mumber of auxiliary source
N=input('Give the total number of the AS : ');
Nc=input('Give the the test point: ');
ra=input('Give the radius of cylinder : ');
a=input('Give the inside auxilary source radious : ');
lambda=c0./f;
x=zeros(1,N);
y=zeros(1,N);
xc=zeros(1,Nc);
yc=zeros(1,Nc);
k0=2*pi./lambda;
for j=1:N
for i=1:Nc
x(j)=a.*cos(2*pi.*(j-1)./N);
y(j)=a.*sin(2*pi.*(j-1)./N);
xc(i)=ra.*cos(2*pi.*(i-1)./Nc);
yc(i)=ra.*sin(2*pi.*(i-1)./Nc);
R(i,j)=sqrt((x(j)-xc(i)).^2+(y(j)-yc(i)).^2);
end
end
WI=zeros(N,N);
Source=zeros(1,N);
Is=zeros(1,N);
%N for the matching points
for j=1:N
% nomizo einai i sinartisi Electricfieldz ousiastika edo pairnei to kuma diegersis
for i=1:Nc
WI(i,j)=(1./4).*k0.*Z0.*besselh(0,2,k0.*R(i,j));
Source(i) =Efieldin(xc(i),yc(i));
end
W = linsolve(WI,Source');
end
for i=1:N
Is(i)=W(i);
end
for k=1:10.*N
xc(k)=ra.*cos(2*pi.*(k-1)./(10.*Nc));
yc(k)=ra.*sin(2.*pi.*(k-1)./(10.*Nc));
%z(k)=abs(Escat(xc(k),yc(k))+Efieldin(xc(k),yc(k)));
z(k)=abs(Escat(xc(k),yc(k)));
final=z';
end
phi=pi;
rho=0:0.1:ra
%plot(rho, Escattheory(rho,phi));
hold on
x=rho.*cos(phi);
y=rho.*sin(phi);
plot(rho,abs(Escat(x,y)))
xlabel('$\rho$','Interpreter','latex')
ylabel('$|E_{s}|$','Interpreter','latex' )
hold off
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!