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

조회 수: 10 (최근 30일)
Matis Tartie
Matis Tartie 2021년 2월 2일
댓글: Jan 2021년 2월 3일
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
Matis Tartie
Matis Tartie 2021년 2월 3일
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 2021년 2월 3일
A hint: While 10^(-6) is an expensive power operation, 1e-6 is a cheap constant.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Mathematics에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by