If: No signal Then: number = "0"

조회 수: 2 (최근 30일)
Iljar Dickhof
Iljar Dickhof 2018년 4월 24일
댓글: Jan 2018년 5월 1일
Is it possible for no signal to be equal to the number zero. As can be seen in the graph, with no signal I get a constant value from the previous time step, until it receives a signal again. These constantes run horizontally in the graph. Is it possible to equate these horizontal lines to zero?
  댓글 수: 3
Ameer Hamza
Ameer Hamza 2018년 4월 24일

How can you decide which output is correct and what is no signal. You mentioned that

"with no signal I get a constant value"

so does this means if you get two constant values like (..., 1, 1, ...) consecutively, the second value is corresponding to no signal. If not? then after how much consecutive constant values, you will be sure that this is no signal.

Image Analyst
Image Analyst 2018년 4월 30일
Do you need to do this on a "live" signal constantly coming in? Or do you want to do this on a signal that has already been captured and put into a variable (possibly after being read in from a file)?

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

답변 (1개)

Jan
Jan 2018년 4월 24일
[B, N] = RunLength(Signal);
B(N > 2) = 0;
Signal = RunLength(B, N);
Now all elements which occur 3 or more times are set to 0.
  댓글 수: 5
Iljar Dickhof
Iljar Dickhof 2018년 4월 30일
Hello,
I installed the C compiler and downloaded the code. All errors are now gone (which I am quite happy with). The graph can be seen in the attached appendix. Thank you for this result.
My code now looks like this:
*>> time = simout4.Time;
>> y = simout4.Data;
>> [B, N] = RunLength (y);
>> B (N> 2) = 0;
>> y = RunLength (B, N);
>> plot (time, y, 'r')
Simout4 is the signal coming from my simulink model.
Now my next question is as follows:
I work in Simulink and wondered if this signal could then be loaded into Simulink again. Then I can use it again in my model.
Jan
Jan 2018년 5월 1일
I do not work with Simulink, so I cannot give a reliable answer. But this is a new question. Please open a new thread, because it allows for keeping the overview, if you post one question per thread only.

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

카테고리

Help CenterFile Exchange에서 Signal Operations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by