Simulink "To Workspace" is outputing 3D array, why?

67 views (last 30 days)
I am passing data to/from Simulink from an .m file. I have most of it understood but one part. One of the signals I pass back from Simulink is being stored in a 3D array but I don't know why. It is a simple time series (i.e. a single column of data). Other (seemingly) identical data is formatted fine.
Here is my example: I have an initial sine wave that I add "13" to. I want to return the initial sine wave and the resulting sine wave, both to my .m file for plotting. The initial sine wave array is of size (51,1). The resulting sine wave array is of size (1,1,51). Why did this happen this way?
[How do I upload a .mld file here?]
function [] = IO_to_simulink_test_function ()
clear all
close all
input_to_simulink = 13; % this is a constant
mySimOptions = simset('SrcWorkspace','current'); %setup current workspace
fprintf('The size of initial_sine_wave is:\n')
fprintf('The size of resulting_sine_wave is:\n')
title('Initial Sine Wave')
title('Resulting Sine Wave')

Accepted Answer

Ryan G
Ryan G on 17 Jul 2012
Edited: Ryan G on 17 Jul 2012
In the constant block for the 13, check the Interpret Vector Parameters as 1-D checkbox.

More Answers (2)

Albert Yam
Albert Yam on 16 Jul 2012
Not really an answer, but I get this as well, what works for me is to squeeze the output:

RAVI ranjan
RAVI ranjan on 6 Oct 2020
It helped me a lot in my research. I appreciate your work thanks mate propacity

Community Treasure Hunt

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

Start Hunting!