![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1406084/image.png)
How in Simulink send one signal from an input to one of several outputs according to a given output number?
14 ビュー (過去 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"
0 件のコメント
回答 (1 件)
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.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1406084/image.png)
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 件のコメント
参考
カテゴリ
Help Center および File Exchange で Event Functions についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!