How in Simulink send one signal from an input to one of several outputs according to a given output number?

24 次查看(过去 30 天)
Simulink has a "Multi-Port switch" element that can be used to switch one of the inputs to a single output.
It is necessary to solve the inverse problem:
to switch the only input signal to the selected output of 10 possible.
How it is better to implement it?
PS
The option with element "Output Switch" does not work. Error "Invalid connection between message and signal ports"

回答(1 个)

Raghava S N
Raghava S N 2023-6-8
I believe what you are looking for is analogous to a digital decoder. I do not believe a Simulink block to do this exists, but you can create one using the MATLAB function block.
And this is the code for it:
function [y0, y1, y2, y3, y4, y5, y6, y7, y8, y9] = fcn(select, input)
y0=0;y1=0;y2=0;y3=0;y4=0;y5=0;y6=0;y7=0;y8=0;y9=0;
switch select
case 0
y0 = input;
case 1
y1 = input;
case 2
y2 = input;
case 3
y3 = input;
case 4
y4 = input;
case 5
y5 = input;
case 6
y6 = input;
case 7
y7 = input;
case 8
y8 = input;
case 9
y9 = input;
end
end
  3 个评论
Alex K
Alex K 2023-6-9
Thanks, but the scheme itself has not yet been formed ... I'm thinking about it. That's why I can't send the code.
So far, the decoder circuit is visible, but it is necessary to block the signal on the unselected outputs so as not to spoil the data in the memory elements connected to the unselected outputs.
In this regard, the question is: is there an element / settings in matlab that controllably blocks the output?

请先登录,再进行评论。

产品


版本

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by