How can I stop C MEX s-function from outputting anything?

조회 수: 1 (최근 30일)
Sunny Talekar
Sunny Talekar 2017년 7월 28일
답변: Sunny Talekar 2018년 2월 23일
I have a C MEX s-function that receives some data, processes it and outputs an array.
I was wondering if there is a way to not output anything (instead of zeros) when the s-function does not receive anything. Inside the s-function I can detect whether anything has been received but I couldn't figure out a way to use this information to inhibit the output (e.g. show nothing when connected to a Display (sink)).
TIA,

채택된 답변

Sunny Talekar
Sunny Talekar 2018년 2월 23일
I managed to achieve the desired outcome by configuring the s-function output as variable-size mode and set the current output dimension to 0 when there is nothing to output.

추가 답변 (1개)

Abhi Sundararaman
Abhi Sundararaman 2017년 7월 31일
It shouldn't be possible to remove the output entirely, since if there is an outport on your s-function block, there will always be an output signal.
However, if you want a visual indicator of the output being invalid (basically the same as outputting nothing), you could try outputting "NaN" instead of zeros.
  댓글 수: 1
Sunny Talekar
Sunny Talekar 2017년 7월 31일
The s-function is designed to output an array of uint8s. I tried setting it to NaN, as suggested, using mxGetNaN(), NAN, std::nan but the output either gets limited to 255 or 0. Not sure, if I'm doing it right.

댓글을 달려면 로그인하십시오.

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by