Simulink "To Workspace" is outputing 3D array, why?
30 views (last 30 days)
Show older comments
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 ()
clc
clear all
close all
input_to_simulink = 13; % this is a constant
mySimOptions = simset('SrcWorkspace','current'); %setup current workspace
sim('simulink_IO_from_m_file_test',[],mySimOptions);
fprintf('The size of initial_sine_wave is:\n')
size(initial_sine_wave)
fprintf('The size of resulting_sine_wave is:\n')
size(resulting_sine_wave)
plot(initial_sine_wave)
title('Initial Sine Wave')
plot(resulting_sine_wave)
title('Resulting Sine Wave')
end
0 Comments
Accepted Answer
More Answers (1)
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: http://www.mathworks.com/help/techdoc/ref/squeeze.html
0 Comments
See Also
Categories
Find more on Outputs in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!