Function with multiple equations? Getting Error "Not enough input arguments."

10 views (last 30 days)
Hello,
I'm trying to create a function that uses the matlab function besselk(nu,z) (Modified Bessel function of the second kind K_0). It should be something like this: K_(r*(sqrt(s^2+s*b))), with s being a Laplace variable. There is somehting wrong in my code, I get the error Not enough input arguments (but i only want one input for this function):
function [K] = my_bessel(f)
D = 10^(-6);
t = 10^(-9);
c = sqrt(D/t);
r = 10*10^(-6);
b = (1/(c*t));
T = 10^(-5);
s = 2*(1i*pi*f) ;
x = r*(sqrt(s.^2+s*b)) ;
K = besselk(0,x) ;
end
To fix this I've tried:
s =@(f) 2*(1i*pi*f) ;
x =@(f) r*(sqrt(s.^2+s*b)) ;
K =@(f) besselk(0,x) ;
This doesn't give me any errors straight away but the function doesn't seem to work when I call for it.
Side note: the reason I'm doing this is K_0(r*(sqrt(s.^2+s*b))) is a transfer function that I'm trying to implement in FPGA. My goal is to do a lookup table approximation of the function because doing the classical bilinear transformation won't work unless the transfer function is a polynomial. I've tried approximating the function to a polynomial. I used taylor and Newton's binomial theorem to approximate it by hand, but only til the second degree. This was not accurate. Maybe someone may have tips for approximating exp(-x) and sqrt() functions on matlab without creating a mega long polynomial?
Anything can help.
Thanks
  6 Comments
Matis Tartie
Matis Tartie on 3 Feb 2021
I've been messing around with it for now and it seems to work (VBBV's version). I still get the same error but in another matlab script I can call the function and plot it. I just get warnings:
Warning: Imaginary parts of complex X and/or Y arguments ignored.
Thanks for your time guys!
Jan
Jan on 3 Feb 2021
A hint: While 10^(-6) is an expensive power operation, 1e-6 is a cheap constant.

Sign in to comment.

Answers (0)

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!