MATLAB: Am I receiving an error related to “OutputPor​tOutputBus​AsStructs” when using model reference and virtual buses

busmodelnonvirtualoutputportoutputbusasstructsparentreferencevirtual

I have a top model containing a model reference block. The outport block inside the reference model is set to be a virtual bus. When I simulate my model, I receive the following error: 
Ports and parameters must match between Model block 'top_model/Model' and referenced model 'ref_model'. Refresh the Model block or revert the changes to the referenced model.
Caused by:
'Output Port 1' of Model block 'top_model/Model' has "OutputPortOutputBusAsStructs" set to "on". The referenced model, 'ref_model', has "OutputPortOutputBusAsStructs" set to "off" for this port. 

Best Answer

Root-cause of the error:
This error is thrown due to a combination of the following two factors:  
  1. There is a mismatch between the reference model outport and the reference block in the top model: 
  • The top model is expecting a nonvirtual bus. 
  • But the reference model checkbox is not selected to" output as nonvirtual bus in parent model": 
  2. Plus, "Ports and parameters mismatch" is set to "error" in Diagnostics > Model referencing in the configuration parameters. 
How to fix this error:
  • If you want to output a nonvirtual bus from the reference model, you can check the option "output a nonvirtual bus in parent model" in the outport inside the reference model (see image above), and the error will be fixed. 
  • If you want a virtual bus, you will need to update the reference model block from the top model, so that the configuration is updated based on the referenced model: 
If the "Ports and parameters mismatch" diagnostic were set to "none", the model reference block is automatically updated. Because it is set to "error" here, you will need to update it manually.