Properties (e.g. Name) are lost when adding a system to array of lti systems
4 次查看(过去 30 天)
显示 更早的评论
When adding several systems to an array of subsystems, I lose the Name property.
e.g.
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?
0 个评论
回答(1 个)
Pratyush Roy
2021-11-5
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!
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Get Started with Control System Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!