Numerically Integral over one variable only

6 views (last 30 days)
Hi,
I am stuggling with numerically intergral ove one variable. Here's a simplified verision of my code:
syms x y
f=x^2+y;
g=3x-y;
fg=f*g;
F=@(y)intergal(@(x) fg,1,3)
After getting F(y), I need to solve the equation F(y)=constant to find the value y.
Is there any numerically way to realize this, since in my real problem, my function can not be solve using definite integrals( "int").
Attached bellow is the real problem I am solving (complicated details omitted, involving Bessel funcitons). The"%Normalization" part is where this question is related to. A and r are the only two variables and I need to integral r to get the equation of A and then solve A from boundary conditions. Thanks a lot for your help!
syms r A
A=A;%assume
B=i*(beta*m)/(mu0*omega)*(1/x1a^2-1/x2a^2)*(I_mda/(x1a*I_ma)-K_mda/(x2a*K_ma))^(-1) * A;
C=I_ma/K_ma * A;
D=I_ma/K_ma * B;
x1=sqrt(beta^2-eps1*k0^2)*r;
x2=sqrt(beta^2-eps2*k0^2)*r;
I_m=besseli(m,x1); I_mp=besseli(m+1,x1); I_md=I_mp+(m/x1)*I_m;
K_m=besselk(m,x2); K_mp=besselk(m+1,x2); K_md=-K_mp+(m/x2)*K_m;
%Field in 1
E1z=A*I_m;
E1r=-i*(beta*r/x1^2)*(A*x1*I_md+i*(m*mu0*omega/beta)*B*I_m);
E1phi=-i*(beta*r/x1^2)*(i*m*A*I_m-(mu0*omega/beta)*B*x1*I_md);
H1z=B*I_m;
H1r=-i*(beta*r/x1^2)*(B*x1*I_md-i*(m*eps0*eps1*omega/beta)*A*I_m);
H1phi=-i*(beta*r/x1^2)*(i*m*B*I_m+(eps0*eps1*omega/beta)*A*x1*I_md);
E1=[E1r, E1phi, E1z];
H1=[H1r,H1phi,H1z];
%Field in 2
E2z=C*K_m;
E2r=-i*(beta*r/x2^2)*(C*x2*K_md+i*(m*mu0*omega/beta)*D*K_m);
E2phi=-i*(beta*r/x2^2)*(i*m*C*K_m-(mu0*omega/beta)*D*x2*K_md);
H2z=D*K_m;
H2r=-i*(beta*r/x2^2)*(D*x2*K_md-i*(m*eps0*eps2*omega/beta)*C*K_m);
H2phi=-i*(beta*r/x2^2)*(i*m*D*K_m+(eps0*eps2*omega/beta)*C*x2*K_md);
E2=[E2r,E2phi,E2z];
H2=[H2r,H2phi,H2z];
%Normalization
S1=matlabFunction(vpa(r*dot(conj(E1),E1)));
S2=matlabFunction(vpa(r*dot(conj(E2),E2)));
S1int=@(A) integral(@(r) S1,0,a);
S2int=@(A) integral(@(r) S2,0,Int);
Asol=double(vpasolve(2*pi*(S1int+S2int)==2*omega*mu0/abs(beta),A));
  2 Comments
Walter Roberson
Walter Roberson on 9 Dec 2019
fg=f*g;
I wonder if you do mean multiplication, or if instead you should be doing a convolution ?
Walter Roberson
Walter Roberson on 9 Dec 2019
Lots of undefined variables, so we cannot run the code to test.

Sign in to comment.

Answers (1)

Navya Seelam
Navya Seelam on 9 Dec 2019
Edited: Navya Seelam on 9 Dec 2019
Hi,
Try the following
syms x y
f=x^2+y;
g=3*x-y;
fg=f*g;
F=int(fg,x,1,3)% to integrate symbolic expression fg with x varying from 1 to 3
s=vpasolve(F==0,y) % solve for y
What is the probem you are facing when you use "int"?

Categories

Find more on Mathematics 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!