MATLAB: Extract the real part of a function as a symbolic expression

bessel functioncomplex variable

I want to extract the real part of a known function. Can anyone point out the reason for which Matlab doesn't want to separate the real and imaginary part of the complex function?
clc, clear
syms w e s m R r I b t z b;
k = i^(3/2)*sqrt(i*w*s*m)*sqrt(1+(i*w*e)/s);
J1 = besselj(1,k*R);
J0 = besselj(0,k*r);
funct = real((k*J0*I*exp(i*(w*t+b*z)))/(2*pi*R*J1));
funct

Best Answer

It cannot figure out what the real and imaginary parts are for that form. For one thing you have not given any constraints on the variables so it must assume they are all complex valued.
But even if you tell it they are all real, you are calling besselj() with parameters that look like they are probably complex (but perhaps might not be, in some circumstances), and besselj() can generally return real or complex values; certainly MATLAB is not going to be able to predict in detail exactly how changes in the various variables are potentially separable into real and complex parts on the output of besselj.