Strange behavior: gain bocks which integrate step inputs
显示 更早的评论
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 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Signal Operations 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!