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
Raghava S N
Raghava S N 2023년 6월 9일
It would be easier to debug if you would share your code/Simulink model.
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?

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

카테고리

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

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by