Effacer les filtres
Effacer les filtres

How can I change the color of a subsystem during simulation based on the value of an input signal ?

1 vue (au cours des 30 derniers jours)
Hello,
I would like to change the color of a subsystem if the input signal exceeds a constant value (or another signal). I found this function (found here : http://fr.mathworks.com/matlabcentral/answers/97099-how-can-i-change-the-color-of-a-subsystem-during-simulation-based-on-the-value-of-an-input-signal-in ) :
function y = fcn(u, t)
%#eml
eml.extrinsic('set_param','get_param','gcs');
y = u;
if u > t
set_param(get_param(gcs,'parent'),'BackgroundColor','red');
else
set_param(get_param(gcs,'parent'),'BackgroundColor','white');
end
But when I try it I get 3 error codes that I don't understand : 1) Unsupported n-D matrix access for n>2. Function 'Subsystem/Embedded MATLAB Function' (#76.131.175), line 7, column 1: "eml.extrinsic('set_param','get-param','gcs')"
2) Unsupported: structure access Function 'Subsystem/Embedded MATLAB Function' (#76.131.144), line 7, column 1: "eml.extrinsic".
3) Errors occured during parsing of Embedded MATLAB function 'Subsystem/Embedded MATLAB Function' (#76).
To simplify, I have a signal that can be 0 or 1, and I would like to have a subsystem block green if the signal is 0 and red if it is 1.
Could you help me please ? I use simulink 6.3 (2005).
Thank you

Réponses (0)

Catégories

En savoir plus sur Simulink Functions dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by