Prev: Differential Evolution - Constrained Optimization
Next: Remove even/odd columns/rows from an array
From: Marcin Polkowski on 10 Oct 2009 14:12 Hi, How can I create my own simulink block with 3-D input and output (RGB image in and out)? I've tried with "MATLAB fcn" and "Level-2 S-function" but both this methods has 2-D limit... Thanks and regards, Marcin
From: Phil Goddard on 10 Oct 2009 21:24 As of R2007a level-2 S-functions have allowed multidimensional inputs and outputs. The trick is to define block.AllowSignalsWithMoreThan2D = true; in the setup function. Below is an example: %%%%%%%%Cut Here%%%%%%%%%% function multiDimSfun(block) setup(block); %endfunction function setup(block) % Register number of ports block.NumInputPorts = 1; block.NumOutputPorts = 1; % Allow multidimensional signals block.AllowSignalsWithMoreThan2D = true; % Setup port properties to be inherited or dynamic block.SetPreCompInpPortInfoToDynamic; block.SetPreCompOutPortInfoToDynamic; % Override input port properties block.InputPort(1).DatatypeID = 0; % double block.InputPort(1).Complexity = 'Real'; block.InputPort(1).DirectFeedthrough = true; % Override output port properties block.OutputPort(1).DatatypeID = 0; % double block.OutputPort(1).Complexity = 'Real'; % Register parameters block.NumDialogPrms = 0; % Register sample times block.SampleTimes = [-1 0]; block.SetAccelRunOnTLC(false); block.RegBlockMethod('SetInputPortDimensions', @SetInpPortDims); block.RegBlockMethod('SetOutputPortDimensions', @SetOutPortDims); block.RegBlockMethod('Outputs', @Outputs); function SetInpPortDims(block, idx, di) block.InputPort(idx).Dimensions = di; %endfunction function SetOutPortDims(block, idx, di) block.OutputPort(idx).Dimensions = di; %endfunction function Outputs(block) block.OutputPort(1).Data = 2*block.InputPort(1).Data; %endfunction %%%%%%% Cut Here %%%%%%%%%%% Phil.
|
Pages: 1 Prev: Differential Evolution - Constrained Optimization Next: Remove even/odd columns/rows from an array |