How to create a complex transfer function?

14 次查看(过去 30 天)
There is a transfer function I want to write in my script but when I attempt to do so, it gives me an error with the following message: "Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters." Here is the code I used to attempt to make the transfer function
Code:
% `1. Write the transfer function in matlab
s = tf('s');
G = 5(1+0.1s)/(s(1+0.5s)(1+(0.6/50)s+(1/50^2)s^2);
My question is how do you create the transfer function as shown in the screenshot?

采纳的回答

Dyuman Joshi
Dyuman Joshi 2023-11-21
编辑:Dyuman Joshi 2023-11-22
You need to provide the multiplication operator. And close the parenthesis properly.
Computers don't understand that two parameters next to each other are supposed to be multipled.
% `1. Write the transfer function in matlab
s = tf('s');
% v v v v v v v v
G = 5*(1+0.1*s)/(s*(1+0.5*s)*(1+(0.6/50)*s+(1/50^2)*s^2))
G = 0.5 s + 5 --------------------------------------- 0.0002 s^4 + 0.0064 s^3 + 0.512 s^2 + s Continuous-time transfer function.
  1 个评论
Walter Roberson
Walter Roberson 2023-11-21
编辑:Walter Roberson 2023-11-21
Computers don't understand that two parameters next to each other are supposed to be multipled.
Computer languages do not just magically support input: they have to be designed as to what character sequences will be considered meaningful, and what the interpretation of those characters should be.
Any computer language that supports multi-character variable names runs into problems in interpretation about whether two adjacent letters are intended to represent two single-character variable names being implicitly multiplied together, or a two-character variable name. Is ij intended to represent i multiplied by j, or is it intended to represent a single variable with a two-character name?
Some computer languages handle the situation by saying that any run of English alphabet letters is a single variable name, but that non-letters interrupt the name and can mean implicit multiplication. So 5ij might be interpreted as 5 times the two-character-name-ij for some languages... but what about ij5 ? Are numbers permitted in variable names? If they are then is 5ij potentially a three-character variable name instead of 5 times something?
It isn't that designers of computer languages cannot make rules so that at least sometimes placing things adjacent implies multiplication... it just gets complicated to nail down useful rules that do not then require some sort of exception mechanism for the cases where multiplication is considered to be implied when the user did not want multiplication.
Further example: if you permit implied multiplication of numbers and adjacent variable names, then is 5e3 to be considered (scientific notation) or is it to be considered 5 times a variable named e3 or is it to be considered 5 times a variable named e then times 3 ? Should it make a difference for the interpretation if a variable named e is currently defined but no variable named e3 is currently defined? If so then if you later define a variable named e3 then should the meaning of 5e3 change ?
Maple is an example of a programming language that can understand some implied multiplication. For example, in Maple 5k+1 would be treated as (5*k) + 1

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 MATLAB Coder 的更多信息

产品


版本

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by