Can you have a Vector of bus signals in MatLab or Simulink

I am trying to process a vector (1-D array) of bus signals in an embedded matlab function and it gives an error when I try to access an element in the vector. I says that vectors of bus signals is not supported in simulink. Could I be using it wrong or is this a limitation in simulink where you are not allowed to have an array of bus signals?

 Accepted Answer

Not clear when you say "a vector of bus signals". Let's say wheel speed, you could have a vector of wheel speed, left-front, left-right, rear-left, rear-right. That can be a vector signal. Simulink supports it. Are you trying to have a bus of these vector signals, such as the four-wheelspeed of vehicle 1, vehicle 2, vehicle 3, etc?
I don't think the Embedded MATLAB Function can handle bus signals with hierarchy. You will need to use BusSelector block outside of the EMF block to make the signal a vector signal.

4 Comments

Yes. An array or vector of vehicles, (i.e. vehicle 1 is the first element, vehicle 2 is the second) and each element in the vector has 4 fields (like you said left-front, left-right, rear-left, and rear-right). If it comes from simulink (created with the bus editor in simulink) and is passed (the entire vector) into an embedded matlab function. Can I just access elements within that functin by using the notation (say it is called vehicleVector in the parameter of the embedded matlab function): vehicleVector(2).left-front. When I tried this I got a weird error that I didn't understand (some cryptic Cg: error) and it ended with an assertion. Don't know if I am accessing it correctly or if there is another problem.
I don't think you can do that. You'll have to use BusSelector block outside of the EMF block.
Thank you. We used the BusSelector and that worked.
Jill: Please report the "Cg: error" that you saw from the MATLAB Function block to the MathWorks Tech Support team. Not sure which release of MATLAB you are using, but at least in the latest release, an array of buses is supported as an input/output to the (Embedded) MATLAB Function block: http://www.mathworks.com/help/toolbox/simulink/ug/bsocrb0.html#bsofy6_
Also, you might want to follow the workflow in the documentation for using buses with the MATLAB Function block to make you are doing it the right way: http://www.mathworks.com/help/toolbox/simulink/ug/bq156zx.html

Sign in to comment.

More Answers (0)

Categories

Find more on Simulink in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!