From: Boulaabi Seif on 7 Oct 2009 03:01 Hello, I'm using a L2 M-files S-function block in a simulink model. The block has a vector as Input and should return a matrix as output. When running the simulation, i have this error message : memory allocation error. At the beginning i had this error : attempt to assign a matrix to a vector. I modified the code by adding the setup of Output dimension and i got a memory allocation error Here is my code, i hope someone can help me function setup(block) %% Register number of input and output ports block.NumInputPorts = 1; block.NumOutputPorts = 1; %% Setup functional port properties to dynamically inherited. block.SetPreCompInpPortInfoToDynamic; block.SetPreCompOutPortInfoToDynamic; % Input and Output ports to be dynamically sized block.InputPort(1).Dimensions = -1; block.OutputPort(1).Dimensions = [-1 -1]; %% Set block sample time to inherited block.SampleTimes = [0 0]; %% Run accelerator on TLC block.SetAccelRunOnTLC(false); %% Register methods block.RegBlockMethod('SetInputPortSamplingMode',@SetInpPortFrameData); block.RegBlockMethod('SetInputPortDimensions', @SetInpPortDims); block.RegBlockMethod('SetOutputPortDimensions', @SetOutPortDims); block.RegBlockMethod('Outputs', @Output); %endfunction function SetInpPortFrameData(block, idx, fd) block.InputPort(idx).SamplingMode = fd; block.OutputPort(1).SamplingMode = fd; function SetInpPortDims(block, idx, di) block.InputPort(idx).Dimensions = di; function SetOutPortDims(block, idx, di) block.OutputPort(idx).Dimensions = di; function Output(block) block.OutputPort(1).Data=transformation(block.InputPort(1).Data'); %endfunction whrere transformation is a function that transform a vector in a matrix. Thanks
|
Pages: 1 Prev: uigetfile problems Next: multidimensional data in svmclassify |