1

J(x)= 1/π integral cos(xsintheta). limits are from 0 to π.

Plot J(2pid/λ) as a function of d/λ in MATLAB for d/λ ranging between 0 and 2. At what distance of separation (in wavelengths) is the correlation between the antennas 0.7, 0 ?

I do not understand how to integrate it in matlab, when i define syms theta and use J_=integral(J,0,pi); there appears an error. secondly, when i integrate it manually, the answer appears 0. Kindly help me with it.

MRule
  • 529
  • 1
  • 6
  • 18
user1398405
  • 63
  • 1
  • 2
  • 10

2 Answers2

2

Unless you really need to calculate this manually, you should use Matlab's built-in besselj function to calculate the zeroth order Bessel function of the first kind:

dlam = 0:0.01:2;
x = 2*pi*dlam;
y = besselj(0,x)
figure;
plot(x,y)

This will be faster and more accurate the performing quadrature.

If you wish to determine the to a high degree of accuracy the points at which y is 0.7 or 0, as opposed to reading them from a plot, you can use symbolic math in conjunction with solve and sym/besselj. Assuming that this is what that part of the question is about (I know nothing about antennas), you can use something like:

syms x;
double(solve(besselj(0,x) == 0.7,x))
horchler
  • 18,384
  • 4
  • 37
  • 73
  • i need to perform the integration actually. The built-in function of Matlab does not integrate it? – user1398405 Nov 24 '13 at 23:22
  • `besselj` calculates it numerically [somehow](http://www.mathworks.com/help/matlab/ref/besselj.html#f79-1042281) – by integration or other means – it's likely faster and more accurate that using any naïve method. In Matlab, calculating this yourself is like writing your own version of `erf` or `gamma`. – horchler Nov 24 '13 at 23:27
  • thanks for your answer. the earlier one is working but the second one is not. There is some error in the formats – user1398405 Nov 24 '13 at 23:45
  • If you're using an old version of Matlab you could try, `double(solve('besselj(0,x)=0.7','x'))` instead, but otherwise I'm not sure what could be wrong unless `which sym/besselj` doesn't find anything. – horchler Nov 25 '13 at 00:22
  • The value of x at y=0.7 is near 0.3 from the graph but the command you mentioned above returns the value 1.1412. – user1398405 Nov 25 '13 at 06:21
  • No, that's not what the plot says. You've switched `x` and `y`. The `solve` function is working correctly and returning the value of `x` when `y` is `0.7` as I indicated in my answer: about `1.1412`. I you want the value of `y` when `x` is `0.7` then you you don't need to do anything fancy – not even a plot – just `besselj(0,0.7)`. I don't know what your variables mean and what you're solving for in terms of antennas, so you're the one who'll need to understand the problem. – horchler Nov 25 '13 at 18:43
0

The integral command does not work on syms, it works on functions. For symbolic integration, the command is int.

I don’t have MATLAB at hand right now to check for typos etc., but something like this should work:

x = 0.1;
integral(@(theta) cos(x.*sin(theta)), 0, pi)/pi

Or even

bessel = @(x) integral(@(theta) cos(x.*sin(theta)), 0, pi)/pi;
bessel(0.1)
Christopher Creutzig
  • 8,656
  • 35
  • 45