Steady-State to Transfer Function Using MATLAB

Click For Summary
SUMMARY

This discussion focuses on resolving an error encountered while using MATLAB to obtain a transfer function for a Controls class. The user faced an issue due to naming their .m file as "ss2tf," which conflicts with MATLAB's built-in function of the same name. The solution is to rename the .m file to avoid this conflict, allowing the script to execute correctly. It is noted that the user is using an older version of MATLAB, specifically MATLAB 2010, which does not exhibit the same error.

PREREQUISITES
  • Basic understanding of control systems and transfer functions
  • Familiarity with MATLAB programming environment
  • Knowledge of state-space representation in control theory
  • Experience with MATLAB version compatibility issues
NEXT STEPS
  • Learn how to properly name MATLAB scripts to avoid function conflicts
  • Explore MATLAB's state-space to transfer function conversion using ss2tf
  • Investigate MATLAB documentation for error handling and debugging techniques
  • Research differences between MATLAB versions, particularly regarding function behavior
USEFUL FOR

This discussion is beneficial for students in control systems courses, MATLAB users encountering function naming conflicts, and anyone seeking to understand state-space representation in MATLAB.

pags920
Messages
20
Reaction score
0
I am trying to use MATLAB to obtain a transfer function, for my Controls class. I will be honest, I have no experience using MATLAB, but our professor insists on us using it to find the transfer function. MATLAB is not a prerequisite for this class. Before I start attempt to find my transfer function, I wanted to make sure I can run the function first. I am having trouble using it. Below is my code that I have on my .m file.

Code:
A=[0 500; -3.3333 -33.3333]
B=[0; 3.3333]
C=[1 0]
D=[0]

[NUM,DEM]=ss2tf(A,B,C,D,1)

When I run this .m file, I get the following error:

Code:
? Attempt to execute SCRIPT ss2tf as a function.

Error in ==> ss2tf at 6
[NUM,DEM]=ss2tf(A,B,C,D,1)

Can anyone help an inexperienced MATLAB user?
 
Physics news on Phys.org
You can't name your .m file with a name that is reserved for a Matlab function (in this case ss2tf). So rename your .m file something other than ss2tf.m and it should work fine.

Unfortunately Matlab doesn't do any checking or enforcement of this other than giving you a vague error like that. But what is happening is that when it gets to the ss2tf function call in your .m file it is confused as to whether you want to call the .m file again or the Matlab function since they both have the same name.
 
Apparently, this command doesn't work with my version of MATLAB. I have an older version, and I tried this on MATLAB 2010 and it works just fine.
 

Similar threads

  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 10 ·
Replies
10
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K