matlabplotbessel-functions

How to plot in matlab using the besselh function with a given range of k (reduced frequency)?


I am using a Matlab function called besselh which gives an exact solution to Theoderon's lift deficiency function for a two-dimensional airfoil executing a simple harmonic motion in incompressible flow with a given range of k.

I am trying to plot the real part of this function with the given range of k. I feel I am missing something really simple in my code. Perhaps, I might be using the for loop wrong by including the "plot" function within the loop?

for k=10^-10:0.2:1.5 %range of k
H=(besselh(1,2,k))/(besselh(1,2,k)+i*besselh(0,2,k)) %Bessel function
plot(k,real(H))
%plot(k,imag(H))
end

Below is a picture of how the plot should look like (solid line).

Any help would be appreciated, thank you in advance!

This is how the plot should look like


Solution

  • You are trying to plot each point individually. Just calculate the function across the whole range for k and then plot:

    k = 10^-10:0.2:1.5; %range of k
    % notice the ./ means element-wise vector division
    H = (besselh(1,2,k)) ./ (besselh(1,2,k) + i * besselh(0,2,k)); %Bessel function
    plot(k,real(H))