Error while using transfer function 'tf'
显示 更早的评论
I tried different inputs as numerator and denominator to create a transfer function using 'tf' command, but my MATLAB leaves this message everytime: 'Incorrect number or types of inputs or outputs for function 'tf''. And this exact code runs perfectly in online MATLAB FYI. Any help is appreciated!
theta_hat = [-1.77627176214971;0.790085804375558;-0.0407175636083817;0.0479175052321617];
a1 = theta_hat(1); a2 = theta_hat(2); b0 = theta_hat(3); b1=theta_hat(4);
num=[b0 b1];den=[1 a1 a2];gz = tf(num,den);
采纳的回答
Please check if you have a user-defined function m-file with the same name as 'tf' that is saved in the current path.
which -all tf
/MATLAB/toolbox/control/ctrlmodels/@tf/tf.m % tf constructor
/MATLAB/toolbox/control/ctrlmodels/@DynamicSystem/tf.m % DynamicSystem method
/MATLAB/toolbox/ident/ident/@idParametric/tf.m % idParametric method
/MATLAB/toolbox/mpc/mpc/@mpc/tf.m % mpc method
/MATLAB/toolbox/shared/controllib/engine/@StaticModel/tf.m % StaticModel method
13 个评论
Please find the attached result i have got in command window here:

Thanks @Keerthik Dhivya, I see it now. It appears that the Control System Toolbox is not installed. The 'tf' function from the Control System Toolbox is necessary to represent linear dynamical systems in transfer function form. This likely explains why it returns the error message 'Incorrect number or types of inputs or outputs for function tf'.
I installed control system toolbox, now its working well.
Thanks for your timely help! @Sam Chak
You're welcome, @Keerthik Dhivya. Feel free to post a new question if you encounter the control design problem. The plant gz(s) is unstable.
theta_hat = [-1.77627176214971;0.790085804375558;-0.0407175636083817;0.0479175052321617];
a1 = theta_hat(1); a2 = theta_hat(2); b0 = theta_hat(3); b1=theta_hat(4);
num=[b0 b1]; den=[1 a1 a2]; gz = tf(num,den)
gz =
-0.04072 s + 0.04792
----------------------
s^2 - 1.776 s + 0.7901
Continuous-time transfer function.
step(gz)

Sure, thanks again!
Hi, did you find an answer to this. I have the exact same problem. It just won't work in the desktop version and I don't have any other m-files withe the same name, Thanks, Joe
What code are you executing, and what error message are you getting?
Do you have the Control System Toolbox installed and licensed?
@joseph timoney, please type this and report what you see on the status output and the errmsg output:
[status, errmsg] = license('checkout', 'Control_Toolbox')
Hi Sam it says
[status, errmsg] = license('checkout', 'Control_Toolbox')
status =
1
errmsg =
0×0 empty char array
I have a sitewide license with my institution. Let me know what you think, thanks,
If you get exactly the same error message, "Incorrect number or types of inputs or outputs for function 'tf'", can you show the full code so that we can test it out?
numerator = 1;
denominator = [2,3,4];
sys = tf(numerator,denominator)
"Incorrect number or types of inputs or outputs for function 'tf'."
Is there a conflict beteen tf in the signal processing toolbox and tf in the control toolbox?
Dyuman Joshi
2023-12-7
编辑:Dyuman Joshi
2023-12-7
That code checks whether a particular item is licensed or not.
Type "ver" in the command window and see if the Control System Toolbox is installed or not.
@joseph timoney, If the Control System Toolbox is installed in your machine, you should see the tf.m file under the control folder. Also use ver as advised by @Dyuman Joshi.

ver
-----------------------------------------------------------------------------------------------------
MATLAB Version: 23.2.0.2436196 (R2023b) Update 4
MATLAB License Number: 0
Operating System: Linux 5.4.233-0504233-generic #202302250651 SMP Sat Feb 25 12:26:27 UTC 2023 x86_64
Java Version: Java 1.8.0_292-b10 with AdoptOpenJDK OpenJDK 64-Bit Server VM mixed mode
-----------------------------------------------------------------------------------------------------
MATLAB Version 23.2 (R2023b)
Simulink Version 23.2 (R2023b)
5G Toolbox Version 23.2 (R2023b)
Aerospace Blockset Version 23.2 (R2023b)
Aerospace Toolbox Version 23.2 (R2023b)
Antenna Toolbox Version 23.2 (R2023b)
Audio Toolbox Version 23.2 (R2023b)
Automated Driving Toolbox Version 23.2 (R2023b)
Bioinformatics Toolbox Version 23.2 (R2023b)
Bluetooth Toolbox Version 23.2 (R2023b)
Communications Toolbox Version 23.2 (R2023b)
Computer Vision Toolbox Version 23.2 (R2023b)
Control System Toolbox Version 23.2 (R2023b)
Curve Fitting Toolbox Version 23.2 (R2023b)
DO Qualification Kit Version 23.2 (R2023b)
DSP System Toolbox Version 23.2 (R2023b)
Database Toolbox Version 23.2 (R2023b)
Datafeed Toolbox Version 23.2 (R2023b)
Deep Learning Toolbox Version 23.2 (R2023b)
Econometrics Toolbox Version 23.2 (R2023b)
Embedded Coder Version 23.2 (R2023b)
Filter Design HDL Coder Version 23.2 (R2023b)
Financial Instruments Toolbox Version 23.2 (R2023b)
Financial Toolbox Version 23.2 (R2023b)
Fixed-Point Designer Version 23.2 (R2023b)
Fuzzy Logic Toolbox Version 23.2 (R2023b)
Global Optimization Toolbox Version 23.2 (R2023b)
HDL Coder Version 23.2 (R2023b)
HDL Verifier Version 23.2 (R2023b)
IEC Certification Kit Version 23.2 (R2023b)
Image Acquisition Toolbox Version 23.2 (R2023b)
Image Processing Toolbox Version 23.2 (R2023b)
Industrial Communication Toolbox Version 23.2 (R2023b)
Instrument Control Toolbox Version 23.2 (R2023b)
LTE Toolbox Version 23.2 (R2023b)
MATLAB Compiler Version 23.2 (R2023b)
MATLAB Compiler SDK Version 23.2 (R2023b)
MATLAB Report Generator Version 23.2 (R2023b)
Mapping Toolbox Version 23.2 (R2023b)
Mixed-Signal Blockset Version 23.2 (R2023b)
Model Predictive Control Toolbox Version 23.2 (R2023b)
Navigation Toolbox Version 23.2 (R2023b)
Optimization Toolbox Version 23.2 (R2023b)
Parallel Computing Toolbox Version 23.2 (R2023b)
Partial Differential Equation Toolbox Version 23.2 (R2023b)
Phased Array System Toolbox Version 23.2 (R2023b)
Powertrain Blockset Version 23.2 (R2023b)
Predictive Maintenance Toolbox Version 23.2 (R2023b)
RF Blockset Version 23.2 (R2023b)
RF Toolbox Version 23.2 (R2023b)
Requirements Toolbox Version 23.2 (R2023b)
Risk Management Toolbox Version 23.2 (R2023b)
Robotics System Toolbox Version 23.2 (R2023b)
Robust Control Toolbox Version 23.2 (R2023b)
Sensor Fusion and Tracking Toolbox Version 23.2 (R2023b)
SerDes Toolbox Version 23.2 (R2023b)
Signal Processing Toolbox Version 23.2 (R2023b)
SimBiology Version 23.2 (R2023b)
SimEvents Version 23.2 (R2023b)
Simscape Version 23.2 (R2023b)
Simscape Driveline Version 23.2 (R2023b)
Simscape Electrical Version 23.2 (R2023b)
Simscape Fluids Version 23.2 (R2023b)
Simscape Multibody Version 23.2 (R2023b)
Simulink 3D Animation Version 23.2 (R2023b)
Simulink Check Version 23.2 (R2023b)
Simulink Code Inspector Version 23.2 (R2023b)
Simulink Coder Version 23.2 (R2023b)
Simulink Control Design Version 23.2 (R2023b)
Simulink Coverage Version 23.2 (R2023b)
Simulink Design Optimization Version 23.2 (R2023b)
Simulink Design Verifier Version 23.2 (R2023b)
Simulink Desktop Real-Time Version 23.2 (R2023b)
Simulink PLC Coder Version 23.2 (R2023b)
Simulink Real-Time Version 23.2 (R2023b)
Simulink Report Generator Version 23.2 (R2023b)
Simulink Test Version 23.2 (R2023b)
Stateflow Version 23.2 (R2023b)
Statistics and Machine Learning Toolbox Version 23.2 (R2023b)
Symbolic Math Toolbox Version 23.2 (R2023b)
System Identification Toolbox Version 23.2 (R2023b)
Text Analytics Toolbox Version 23.2 (R2023b)
Vehicle Dynamics Blockset Version 23.2 (R2023b)
Vehicle Network Toolbox Version 23.2 (R2023b)
Vision HDL Toolbox Version 23.2 (R2023b)
WLAN Toolbox Version 23.2 (R2023b)
Wavelet Toolbox Version 23.2 (R2023b)
Wireless HDL Toolbox Version 23.2 (R2023b)
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Introduction to Installation and Licensing 的更多信息
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
