Programmatically duplicate signal in Simulink
Afficher commentaires plus anciens
Hello,
I cannot seem to find a simple way to programmatically replicate a signal into a vector in Simulink. For example, I'd like to create a trivial subsystem which has a single inport and outport which is configured only by a single parameter: N. The subsystem would have a single mux inside (with N inputs) and the inport would connect to all mux inputs. The below screenshot represents what I am referring to for the case of N=8. The only thing I can't seem to figure out is how to programmatically connect the inport to all N mux inputs. Can someone please assist?

Thanks!
Réponse acceptée
Plus de réponses (1)
Scott Tatum
le 30 Mar 2022
insert a gain witht the value of ones(N,1)
h_gain = add_block('simulink/Math Operations/Gain','myModel/repgain','Gain',sprintf('ones(%d,1)',N));
% connect lines
add_line('myModel','In1/1','repgain/1') % input line
add_line('myModel','repgain/1','Out1/1') % output line
Catégories
En savoir plus sur Simulink Functions dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!