Strange behavior: gain bocks which integrate step inputs
조회 수: 2 (최근 30일)
이전 댓글 표시
Hi all!
I have the following problem. I have three signals which pass into some Compare to constant block. The Compare to constant blocks clearly output a boolean value. Let's call these boolean variable A,B and C. Now, depending on the values of A,B,C I should select an appropriate input of a 4-port switch. Therefore, I need to a function that takes the values of A,B,C as input, and which output an integer between 1 and 4.
This is my solution. I first convert A,B, C in integer through the well-known formula y = A*4+B*2+C*1, where A is the MSB and C is the LSB. Such formula is implemented through 3 Gain Blocks (with gains 4,2 and 1 respectively) blocks and a sum block with three inputs. Then the value of y is used as input of a look-up table which maps y into {1,2,3,4}, depending on which input of the switch I need.
However, I have the problem that the gain blocks "integrate" the boolean values. For instance, as I have a neat step at the input of the gain block (i.e. something like that _| ), but the output looks like a ramp (i.e. something like that _/). This leads to unexpected behavior of the system. I have tried to reduce the fundamental step size (I am using a fixed-step solver), and the situation gets a bit better, but not completely solved. How can I solve this?
Thanks! :)
댓글 수: 0
채택된 답변
Doug Eastman
2013년 4월 10일
The issue with the lines being slanted is due to the fact that Simulink sees these signals as continuous so it will connect the fixed-step discrete points with lines rather than stair-steps. The slopes don't actually matter though since the simulation is not being executed between the two points. If you would like to see the stair-step you could discretize the signals using a Zero-order Hold block with the same sample rate as your base step size.
Alternatively you could use a variable-step solver with zero crossing detection so that you will get a time step at the exact moment of transition for each of the compare to constant blocks. That will also product a clean vertical edge with a continuous signal.
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 General Applications에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!