Can I display the value of an output of my block on its mask?

조회 수: 14 (최근 30일)
Jan
Jan 2018년 3월 23일
댓글: Jan 2022년 7월 28일
Is it possible to mimic the behavior of the display sink block on my own masks? I would like to modify the value of a slowly varying signal inside my block, deliver the output to a subsequent block and display the output result (an integer) on the mask. This avoids having to fork off the output signal to an additional display block on the top level diagram.

채택된 답변

Andrea Carignano
Andrea Carignano 2021년 1월 28일
편집: Andrea Carignano 2021년 1월 28일
Hi Jan,
If I understood correctly you have a subsystem like this:
Inside the block you have for example:
And you want to see the value of OUTPUT displayed on SUBSYSTEM mask
SOLUTION 1: Show the value label of the signal (not exactly what you want)
SOLUTION 2 (nice but not recommended because it can slow down the simulation)
  • Add a hidden edit box to the SUBSYSTEM mask and choose a name for the parameter (example "x")
  • In Icons & Ports add the code:
disp(get_param(gcb,'x'))
  • Add a Matlab function block inside SUBSYSTEM with 1 input from the value you want to display and no output.
  • Use this code in the matlab function block
function fcn(u)
coder.extrinsic('gcb','set_param','get_param');
p = get_param(gcb,'parent');
set_param(p,'x',sprintf('%.0f',u));
end
  • (Optional but recommended) set the matlab function block Sample Time to avoid a slowdown of the simulation
  • In the end you have the value of the output displayed on your mask during simulation

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Author Block Masks에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by