【发布时间】:2013-07-17 15:02:56
【问题描述】:
我想写一个块,它从选定的目录发送所有图像文件。
图像大小不同,因此输出信号大小应该不同。
很遗憾,我无法找到在每一步更改信号大小的方法。这里有许多未记录的功能,例如
block.OutputPort(1).DimensionsMode = 'Variable';
和
block.OutputPort(1).CurrentDimensions = [1 block.InputPort(1).Data];
等等。我还无法推断出正确的方法来操作所有这些东西......
更新
比如这个 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;
导致错误
输出端口 1 的变量尺寸分配无效 'Test_01/Level-2 MATLAB S-Function'。可变维数 是 1。但是,MATLAB 数组的长度是 2
为什么?
【问题讨论】:
-
是的,我引用了这个例子。