I want to write a block, which sends all image files from selected directory.
Images are of different sizes, so output signal size should vary.
Unfortunately I was unable to find a way to change signal size at each step. There are many of undocumented features here, in examples like
block.OutputPort(1).DimensionsMode = 'Variable';
and
block.OutputPort(1).CurrentDimensions = [1 block.InputPort(1).Data];
and so on. I was unable to deduce correct way to operate all this stuff yet...
UPDATE
For example, this S-function
function Test_SF_01(block)
% Level-2 MATLAB file S-Function.
setup(block);
function setup(block)
% Register number of ports and parameters
block.NumInputPorts = 0;
block.NumOutputPorts = 1;
block.NumDialogPrms = 0;
% Setup functional port properties to dynamically inherited
block.SetPreCompOutPortInfoToDynamic;
% Register the properties of the output port
block.OutputPort(1).DimensionsMode = 'Variable';
block.OutputPort(1).SamplingMode = 'Sample';
% Register sample times
% [-1, 0] : Inherited sample time
block.SampleTimes = [-1 0];
% Register methods called at run-time
block.RegBlockMethod('Outputs', @Outputs);
function Outputs(block)
block.OutputPort(1).CurrentDimensions = floor(rand(1,2)*10)+1;
causes an error
Invalid variable dimensions assignment for output port 1 of 'Test_01/Level-2 MATLAB S-Function'. The number of variable dimensions is 1. However, the length of the MATLAB array is 2
why?