How to export a column vector from a "MATLAB Function" block without seeing the “Cannot Save Outputs in the ‘Array’ Format” error?

I have a Simulink model which contains a "MATLAB Function" block. The "MATLAB Function" block code outputs a column vector of values.
However, when trying to output these values using an "Outport" block, I see the error message below:
Cannot save outputs in the 'Array' format because signals connected to the root outports of model 'MyModel' are not scalar or 1-D arrays. Set 'Configuration Parameters > Data Import/Export > Format' to 'Dataset', 'Structure' or 'Structure with time'.
How can I resolve this error to export a column vector from my "MATLAB Function" block?

 채택된 답변

MATLAB interprets a column vector as a matrix of size [N x 1] while Simulink interprets a column vector as a 1-D array containing N values.
Therefore, to resolve the issue, you may either:
  1. Go into the "MATLAB Function" block's code under the "FUNCTION" tab, then select "Edit Data". Select the output variable which is causing the error in the right-hand side tab and in the code. Open the "Advanced" drop-down menu and check the option to "Interpret output column vectors as one-dimensional data".
  2. Use a "Reshape" block with the "Output Dimensionality" parameter set to "1-D array" to define the [Nx1] matrix as a 1-D array.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Programmatic Model Editing에 대해 자세히 알아보기

제품

릴리스

R2025b

Community Treasure Hunt

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

Start Hunting!

Translated by