How to create a complex transfer function?

14 Ansichten (letzte 30 Tage)
Michael
Michael am 21 Nov. 2023
Bearbeitet: Dyuman Joshi am 22 Nov. 2023
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?

Akzeptierte Antwort

Dyuman Joshi
Dyuman Joshi am 21 Nov. 2023
Bearbeitet: Dyuman Joshi am 22 Nov. 2023
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 Kommentar
Walter Roberson
Walter Roberson am 21 Nov. 2023
Bearbeitet: Walter Roberson am 21 Nov. 2023
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

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu MATLAB Coder finden Sie in Help Center und File Exchange

Produkte


Version

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by