%% Preallocate ROS Message Array
% To preallocate an array using ROS messages, use the arrayfun or cellfun functions instead of repmat. These functions properly create object or cell arrays for handle classes.
% Preallocate an object array of ROS messages.

msgArray = arrayfun(@(~) rosmessage('std_msgs/String'),zeros(1,50));

%
% Preallocate a cell array of ROS messages.

msgCell = cellfun(@(~) rosmessage('std_msgs/String'),cell(1,50),'UniformOutput',false);

% Copyright 2012 The MathWorks, Inc.
%