Simulink "To Workspace" is outputing 3D array, why?
30 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
更多回答(1 个)
Albert Yam
2012-7-16
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Outputs 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!