Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.
|
|
|
|
Simulink queri
Posted:
Feb 11, 2009 3:54 PM
|
|
Hi, I am Vaibhav
I want to do audio processing in simulink using level 2 m file For that i need frame based input from wavedevice/wavefile and then process it to extarct features like ZCR, Short time energy,spectral centroid etc
For that I have written m code function vs3(block) % Level-2 M file S-Function for unit delay demo. % Copyright 1990-2004 The MathWorks, Inc. % $Revision: 1.1.6.1 $
setup(block); %endfunction
function setup(block) block.NumDialogPrms =0; %% Register number of input and output ports block.NumInputPorts = 1; block.NumOutputPorts = 1;
%% Setup functional port properties to dynamically %% inherited. block.SetPreCompInpPortInfoToDynamic; block.SetPreCompOutPortInfoToDynamic; block.InputPort(1).SamplingMode = 'Inherited'; block.InputPort(1).Dimensions = [256 1];%i/p from wavedevice/wavefile is 256*1 block.InputPort(1).DirectFeedthrough = false;
block.OutputPort(1).Dimensions = [256 1]; %% Set block sample time to inherited block.SampleTimes = [0.1 0]; %% Register methods block.RegBlockMethod('PostPropagationSetup', @DoPostPropSetup); % block.RegBlockMethod('InitializeConditions', @InitConditions); block.RegBlockMethod('Outputs', @Output); block.RegBlockMethod('Update', @Update); %endfunction
function DoPostPropSetup(block)
%% Setup Dwork block.NumDworks = 1; block.Dwork(1).Name = 'x0'; ***************************************** block.Dwork(1).Dimensions =[256 1]; ***************************************** block.Dwork(1).DatatypeID = 0; block.Dwork(1).Complexity = 'Real'; block.Dwork(1).UsedAsDiscState = true;
%endfunction
%function InitConditions(block)
%% Initialize Dwork block.Dwork(1).Data = block.DialogPrm(1).Data; endfunction
function Output(block)
block.OutputPort(1).Data = block.Dwork(1).Data; %endfunction
function Update(block)
block.Dwork(1).Data = block.InputPort(1).Data; %endfunction
For line between the star I am getting error
Error evaluating registered method 'PostPropagationSetup' of M-S-Function 'vs3' in 's2/Level-2 M-file S-Function'. Invalid dimensions specified for Dwork 1 of 's2/Level-2 M-file S-Function'. Dwork must be a vector, and its width must be a positive integer. The following is the MATLAB call stack (file names and line numbers) that produced this error:
Can anybody help me?
|
|
|
|