# Matlab transfer function problem

• MATLAB
• MechatronO
In summary, the conversation discusses a transfer function and its definition, as well as the unexpected results when using certain MATLAB routines to calculate the transfer function. The issue is resolved by using a different code structure and properly defining the variable s.
MechatronO
I have a transfer function

L(s) = A(s)/B(s)

that I call Ls.

However, when defining

H(s)= L(s)/(1+L(s))

by

Code:
%%
Ls =

-70.6s^2 - 2003 s + 3375
--------------------------
s^3 + 119.6 s^2 + 2806 s

%%

Hs = Ls / (1+Ls)

things go wild. The highest exponent power doubles or so and I get several extra poles or zeros. What I should get is

H(s) = A(s) / ( B(s)+A(s) )

which is the exact result. This I can achieve in MATLAB by

Code:
[As,Bs] = tfdata(Ls,'v');

Hs= tf(As,Bs+As)

and the result from this are exactly the expected.

However, why won't

Code:
 Hs = Ls / (1+Ls)

work?

Are matlabs routines that bad? Or am I doing something wrong?

Is s a vector?

No,

s= tf('s');

MechatronO said:
Code:
%%
Ls =

-70.6s^2 - 2003 s + 3375
--------------------------
s^3 + 119.6 s^2 + 2806 s

%%
[/QUOTE]
This doesn't look like a valid Matlab statement to me. I would write it as
Ls = ( -70.6s^2 - 2003 s + 3375 ) / ( s^3 + 119.6 s^2 + 2806 s );
(It presumes that s has already been defined earlier.)

I understand your frustration with this issue. It is important to note that MATLAB is a powerful tool for scientific and mathematical computations, but it is not infallible. It is possible that there may be a bug in the transfer function calculation routine, or that there is a limitation in the way MATLAB handles certain transfer functions.

In order to troubleshoot this issue, I would suggest reaching out to MATLAB technical support or consulting with other experts in the field who have experience with similar transfer function problems. They may be able to provide insight into the underlying issue and offer potential solutions.

In the meantime, it is always a good practice to double-check your calculations and try alternative methods, as you have already done with the [As,Bs] = tfdata(Ls,'v') and tf(As,Bs+As) methods. This approach can help identify any potential errors or limitations in the code.

Overall, it is important to remember that while MATLAB is a powerful tool, it is not perfect. As scientists, it is our responsibility to critically evaluate our results and seek out alternative methods when needed.

## 1. What is a transfer function in Matlab?

A transfer function in Matlab is a mathematical representation of the relationship between the input and output of a dynamic system. It is typically used in control systems and signal processing to analyze the behavior of a system.

## 2. How do I create a transfer function in Matlab?

To create a transfer function in Matlab, you can use the tf function. This function takes in the coefficients of the numerator and denominator of the transfer function as parameters and returns a transfer function object.

## 3. How do I plot the frequency response of a transfer function in Matlab?

To plot the frequency response of a transfer function in Matlab, you can use the bode function. This function takes in the transfer function object as a parameter and plots the magnitude and phase response of the transfer function over a specified frequency range.

## 4. How do I use transfer functions in a feedback loop in Matlab?

To use transfer functions in a feedback loop in Matlab, you can use the feedback function. This function takes in the transfer function objects for the forward and feedback paths as parameters and returns the overall transfer function for the closed-loop system.

## 5. Can I convert a transfer function to a state-space representation in Matlab?

Yes, you can convert a transfer function to a state-space representation in Matlab using the tf2ss function. This function takes in the transfer function object as a parameter and returns the state-space representation of the system in the form of matrices.

• Engineering and Comp Sci Homework Help
Replies
1
Views
328
• MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
• Engineering and Comp Sci Homework Help
Replies
3
Views
805
• MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
• MATLAB, Maple, Mathematica, LaTeX
Replies
11
Views
3K
• Engineering and Comp Sci Homework Help
Replies
5
Views
1K
• MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
2K
• MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
6K
• Engineering and Comp Sci Homework Help
Replies
1
Views
834
• MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
6K