Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

simulink: add a legend in scope block

591 views
Skip to first unread message

pietro

unread,
Jan 27, 2011, 9:00:05 AM1/27/11
to
Hi guys,

how can I add a legend in a scope block?

thanks

Pietro

Phil Goddard

unread,
Jan 27, 2011, 11:35:05 PM1/27/11
to
There is no in-built method for putting a legend on a scope.

However, since a scope is just a MATLAB figure window in disguise you can with a little bit of careful effort use standard Handle Graphics, along the lines of

% get handles to all scopes (the scope must have been opened at least once for this to work)
>> hScopes = findall(0,'Tag','SIMULINK_SIMSCOPE_FIGURE');

% Assume we want to put a legend on the first scope
% Get the axes on the scope
>> hAxes = findall(h(1),'Type','axes');

% Assume we want to put a legend on the first axis on the scope, and that
% it has 3 signals on it.
>> legend(hAxes(1),{'signal1','signal2','signal3'},'Color',[1 1 1]);

Note that the legend will not update or do anything else automatically if you change the signals going into the scope.

Phil.

Tannistha

unread,
Mar 16, 2011, 9:10:07 AM3/16/11
to
Hi Phil thanks for the info. I have multiple scopes in a multilayer model. some scopes show different values for example the three phase currents and the resultant space vector in one scope. i would like to add legends at the top or side, saying, yellow phase1, purple phase 2,blue phase 3 etc, is there any way to do that?

Clemens

unread,
Oct 19, 2012, 4:26:08 AM10/19/12
to
"Tannistha" wrote in message <ilqcrf$90e$1...@ginger.mathworks.com>...
> Hi Phil thanks for the info. I have multiple scopes in a multilayer model. some scopes show different values for example the three phase currents and the resultant space vector in one scope. i would like to add legends at the top or side, saying, yellow phase1, purple phase 2,blue phase 3 etc, is there any way to do that?

Had the same problem yesterday (with 2011b) and found this solution using simplot:
http://blogs.mathworks.com/seth/2010/06/22/how-to-customize-the-simulink-scope/

Since 2012a there will be an additional option in the scope parameters:
http://blogs.mathworks.com/seth/2012/03/12/legends-for-simulink-scopes/

BR,
C ;-)
0 new messages