I have two identical bus structures in Simulink, with different values. One is the (CAN) bus from a real vehicle, the other is an identical simulated (CAN) bus in Simulink. I want to compose a mixed, identical output bus with these, where some signals are taken from the first bus, and others from the second bus as is shown.
I want to switch with a third identical bus, containing a value for each signal determining to switch the signal to the output from either bus 1 or bus 2. Schematically, it looks like the grey section:
As you can see, the first signal (Rpm, 3) is taken from the vehicle bus, the second signal (Spd, 6) is taken from the simulated bus. Regarding structure, the output bus is identical to the two input buses. The principle in the schematic works, but I have over 500 signals, so this method is not really applicable anymore.
How can I do this without having to manually route 500 signals?
I'm thinking about a MATLAB function block, but suggestions are welcome.
MATLAB Function
block is the easiest was to do this. – Phil Goddardlogical indexing
to do the assignments, rather than a loop. But either way, note that the code withing theMATLAB Function
block is being converted to C and compiled, it is not running in the interpreter, so speed shouldn't be an issue. – Phil Goddard