Azzera filtri
Azzera filtri

Properties (e.g. Name) are lost when adding a system to array of lti systems

4 visualizzazioni (ultimi 30 giorni)
When adding several systems to an array of subsystems, I lose the Name property.
fc = 40; % Cross-over frequency in Hz
wc = 2*pi*fc;
lpf = ss(tf(1, [1/wc, 1], 'Name', 'LPF')); % LTI system of a 1st order low-pass filter
hpf = ss(tf([1/wc, 0], [1/wc, 1], 'Name', 'HPF')); % LTI system of a 1st order high-pass filter
sys(:,:,1,1) = lpf;
sys(:,:,1,2) = hpf;
The LTI systems lpf and hpf have the Name property set, but the array of LTI Systems sys doesn't have it anymore.
I pass the array to a custom function to create the Bode plots of both filters at once and I'd like to add the legend using the Name of the systems to identify the curves.
Trying to repair the omission by using the set command doesn't work
set(sys(:,:,1,1), 'Name', 'LPF');
This gives the error message
Error using DynamicSystem/set (line 7)
The first input argument of the "set" command must be a named variable.
Any ideas what may be causing this/what I am doing wrong?

Risposte (1)

Pratyush Roy
Pratyush Roy il 5 Nov 2021
Hi Jan,
By design, LTI array itself has a name and it is shared when you index into array elements. For example:
sys.Name = 'xyz';
sys(:,:,1,2).Name % display 'xyz'
In other words, after you stack individual LTI systems into an array, the individual names will get lost and it is by design.
If retaining individual names are important, you can store LTI systems in a cell array as a workaround.
sys{1} = lpf;
sys{2} = hpf;
However, we would lose some benefits available only from LTI array such as using "bode(sys)".
Hope this helps!
  1 Commento
Jan il 5 Nov 2021
Modificato: Jan il 5 Nov 2021
Thanks Pratyush,
Just checked the parameters one-by-one and found out that the array retains all properties that are defining the behavior of the LTI models in the array (e.g. 'InputDelay').
However, I was surprised to see that the other naming properties e.g. 'StateName', 'InputName' and 'OutputName' are also retained by the array. Apparently, the array of LTI systems is not restricted to have only numerical properties.
Of course these naming properties could also be used to identify the individual systems for my legend. Unfortunately, all elements (LTI systems) in the array get the same 'OutputName' property.
This raises the question why this is designed that way. You say it is 'by design' that the names of the individual LTIs are lost and only the complete array can have a name. Yet, the Input-, Output- and StateName properties are passed on to the elements in the array but they all adopt the value of the first element. This is at least inconsistent, at worst erroneous, most probably: simply forgotten.
As it is good practice to name variables and properties as much as possible, I would prefer that the array could have a name in addition to the individual LTI systems in its elements. Would you happen to know why it was decided not to be implemented, and if I can make a feature request to still get it implemented?

Accedi per commentare.




Community Treasure Hunt

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

Start Hunting!

Translated by