user1296932
user1296932

Reputation:

Creating a custom transfer function in matlab

I need to create a transfer function for a custom equation in order to input the transfer function as a variable into another function. The equation I need to transform into a tf is:

y = exp(-(x^2))

I can't make it work, I tried using:

s = tf('s');
H = exp(-(s^2));

But I get the following error:

Error using tf/exp (line 34) The input argument of the "exp" command must be a transfer function of the form -M*s.

Can anyone tell me what I'm doing wrong here?

Upvotes: 0

Views: 1329

Answers (2)

anon
anon

Reputation:

In MATLAB, exp(-T*s) represents a time delay of T seconds, which is the only allowable use of the exp function in transfer functions in MATLAB (using basic MATLAB and the Control System Toolbox since you mentioned the tf function). Since exp(-x^2) is not in this form, it does not represent a time delay and therefore is not recognized by MATLAB as a valid transfer function.

If, however the equation y = exp(-x^2) is a time domain equation, i.e. y(t) = exp(-x(t)^2), then you first need to convert this equation to s domain using the Laplace transform. However, the Laplace transform of exp(-x^2) cannot be represented as a transfer function in MATLAB since it is a nonlinear function.

In either case, you may use linearization to obtain a linear approximation of the exponential term or its Laplace transform and then use that to obtain its transfer function.

Upvotes: 2

SPieiga
SPieiga

Reputation: 3

Can you elaborate on how you are passing this transfer function to another function as a variable? How is it being used in the other function?

If you are trying to just create a generic function, you can do:

y=@(x) exp(-(x^2));

and then you can do things like myFunction(y(2)) or if you want to use it as a symbolic expression, you can do:

syms s;
y=@(x) exp(-(x^2));
myFunction(y(2+3*i)); %or
myFunction(y(s));

Upvotes: 0

Related Questions