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:
3. Inside of my Function I can use now this variable
D
as structure.
And I get nonvirtual output:
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?