How to create a transfer function with Gain K
Mostra commenti meno recenti
there was a previous post about this but it was never resolved
how does one create a TF with K = to some gain? except K is not known at the moment
for example
K*(S+2)/(S+3)
Once you create a tf data type you can not multiple it by a symbolic type.
How do you create a tf with an un specified gain?
Risposte (2)
Walter Roberson
il 1 Ott 2016
8 voti
11 Commenti
Robert
il 1 Ott 2016
Walter Roberson
il 2 Ott 2016
TL;DR: MATLAB does not support that operation.
Walter Roberson
il 2 Ott 2016
"A link does not suffice for help on this forum"
Robert, can you expand upon the source of your claim that links do not suffice for help on this forum? Is it drawn from your experience in answering hundreds of questions here?
Walter Roberson
il 2 Ott 2016
k = realp('k',1); k.Minimum = 0;
ppp = tf([k 2*k], [1 3])
This creates a genss (General State System)
or
K = tunableGain('K', 1, 1); K.Gain.Minimum = 0
qqq = K * tf([1 2], [1 3]);
This also creates a genss.
At any one point, a genss has a definite value assigned to the parameter. You can, for example,
bode(ppp)
and with the above configuration it would be the same as bode() applied to tf([1 2], [1 3]) because the 1 of the realp was used to assign 1 to the parameter. But if you
bode(qqq)
you will get empty plots, because the default value for a tunableGain is all 0 -- those 1 have to do with the size of the array used, 1 x 1.
You can use
setTunedValue(qqq, 'K', 2)
but be warned this returns a new genss rather than modifying the old, so you would probably want
qqq = setTunedValue(qqq, 'K', 2)
and
getTunedValue(qqq, 'K')
to view the current value of the parameter.
The setting methods are exactly the same for ppp, using the appropriate variable name.
This blocks can be used in systems but it must be remembered that they always have a particular current numeric value when queried. Some tools such as systune() can recognize the allowed variability with mins and max and use it to adjust the overall system towards particular goals.
You can do arithmetic with these genss and they will retain knowledge of the tunability in representing the output -- you can even do
z = 4*ppp / (1+qqq);
bode(z)
However, none of these is a transfer function with a symbolic parameter. A symbolic parameter would have an indefinite value until a definite value was subs()'d in. You would be able to use operations such as laplace() on a symbolic transfer system:
>> syms s C
>> laplace(C*(s+2)/(s+3),s)
ans =
C/s - C*exp(3*s)*expint(3*s)
MATLAB does not offer any direct Control System facilities to work with symbolic expressions -- just whatever you can put together from the symbolic toolkit (the MuPAD engine has no built-in Control System library, no transfer function analysis.)
I notice that you are working from the command line. The tunable systems and parametric systems are particularly handy in Simulink models.
If you are looping over values rather than needing a symbolic transfer function specifically (e.g., for laplace transform), you can just avoid all of this by using something like
gaink = @(k) tr(k*[1 2], [1 3]);
and then
for k = linspace(0.01, 3, 50)
ppp = gaink(k);
...
end
But your question did not permit looping. Your question was specifically for the case where the k value is not determined at the time the transfer function was created. MATLAB does not support that. However, using the methods described above for creating tunable systems, it might possibly support doing whatever it is you are actually doing.
Walter Roberson
il 2 Ott 2016
"So instead of sending me on a wilde goose chase why not just say the one line answer"
Because those links gave input from multiple people, and gave context and reasons? Would it have been somehow better if I had copied and pasted the previous discussion so that you would be saved the effort of clicking two links where the content was already written?
I ask again: Can you expand upon the source of your claim that links do not suffice for help on this forum? Are we volunteers obligated to give each person a personalized response that gives them the exact answer they were looking for? Are we not permitted to refer people to the places where the information is to be found or from which it is reasonably deducible?
When the answer is "MATLAB does not have that facility at this time", are we volunteers obligated to write new routines and extend toolboxes in integrated ways to provide the facilities the users were asking about?
Was it your understanding that we who answer Questions here are paid employees of Mathworks, or otherwise paid by someone to answer the Questions here, and that we are so paid to do so even on weekends??
Because that is completely not the case. In my five 3/4 years of answering questions here, my total compensation for doing so has been one Mathworks ball-cap, and one medal of thanks from Mathworks.
Which of my bills is being paid by your opinion of how I am obligated to answer questions here?
Robert
il 2 Ott 2016
Walter Roberson
il 2 Ott 2016
The 4 reputation points I get from your clicking Accept doesn't pay the bills either.
How about this proposal: you, being a reasonable and intelligent person, read links when they are provided, and then if you are still uncertain, you explain your needs further and ask questions ?
At the moment we still do not know how you want to be able to use the facility you requested, so we do not know if one of the genss solutions fits your situation, or if you do need to be able to do symbolic manipulation of transfer functions (and if so, what sorts of manipulations.)
"[...] is ridiculous for a program that is as "powerful" as matlab"
MATLAB was written by humans with finite lifetime and finite productivity, writing and testing and documenting, and for a so-far-finite amount of time. So, like every other program so far created, it has finite facilities. There is always going to be something it cannot do.
Indeed, as human knowledge is now estimated to be doubling every 12 to 18 months, unless the productivity of the Mathworks developers can increase at least as quickly, MATLAB is going to fall further and further behind in portion of knowledge covered -- as will all other human-written programs.
Star Strider
il 2 Ott 2016
‘human knowledge is now estimated to be doubling every 12 to 18 months’
The parallel with Moore’s Law is too tempting to ignore. Correlation, causation, some universal limit, or something else?
Walter Roberson
il 2 Ott 2016
When I was looking though the material for reference on the rate of change, it was not clear to me that the sites were distinguishing between "knowledge" and "data". For example they are mapping all of the neurons of a brain, which is producing masses of data, but we still need to analyze it to turn it into knowledge.
If the figure is really more about "data" then it makes sense for there to be a connection to Moore's law: as computers get faster and memory (and hard drive) prices drop, then for a constant price you can afford to increase the data stored.
Star Strider
il 2 Ott 2016
For all except the essentially ‘pure’ deductive disciplines of pure mathematics, philosophy, and such (at least in my opinion), the difference between ‘data’ and ‘knowledge’ may not be distinct. In medicine for example, hardware and software advances make the ‘genomic revolution’ possible. It takes some very bright people to interpret the data, but in the absence of current technology to do the extremely rapid sequencing and intial processing of those results, those same data, and the understanding of the genetic contributions to disease that derive from them, would be years if not decades in the future.
Walter Roberson
il 29 Set 2017
5 voti
Ping Robert. Since I took the time to list the possibilities that are supported by MATLAB and described how they differed from what you appeared to be asking, how about if you either Accept my answer or else clarify what more response you are hoping for.
1 Commento
Jack Borg
il 23 Apr 2023
I can't accept it but I would if I could, thankyou!
Categorie
Scopri di più su Tuning Goals in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!