2

I tried to output data from MATLAB Function block as Bus signal. As you now it can be virtual and non-virtual.

Workaround

I know how to create it as nonvirtual: 1. Create Bus object at workspace;

bussignal(1) = Simulink.BusElement;
bussignal(1).Name = 'Q';
MyBus = Simulink.Bus;
MyBus.Elements = bussignal;

2. Define output properties of my Function Block as Bus: myBus at Model Explorer:enter image description here 3. Inside of my Function I can use now this variable D as structure. And I get nonvirtual output: enter image description here

Question: How to make it virtual? I want to use virtual because it doesn't create copies of data and don't create structures (avoid additional memory allocation) so can work faster for big projects. I can make a lot of outputs and then use Bus Creator block but how to do it programmatically inside of Function?

Mikhail_Sam
  • 10,602
  • 11
  • 66
  • 102

1 Answers1

2

MATLAB Function supports only non-virtual buses. It converts virtual bus signal inputs to non-virtual buses. See documentation at

http://www.mathworks.com/help/simulink/ug/how-structure-inputs-and-outputs-interface-with-bus-signals.html

When you need to convert input bus type to a struct for MATLAB code in the MATLAB Function block it cannot be virtual that can have noncontiguous memory.

Navan
  • 4,407
  • 1
  • 24
  • 26