The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Simulink queri
Replies: 1   Last Post: Feb 17, 2013 5:35 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Vaibhav chidrewar

Posts: 1
Registered: 2/11/09
Simulink queri
Posted: Feb 11, 2009 3:54 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

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: $



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.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);


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;


%function InitConditions(block)

%% Initialize Dwork
block.Dwork(1).Data = block.DialogPrm(1).Data;


function Output(block)

block.OutputPort(1).Data = block.Dwork(1).Data;


function Update(block)

block.Dwork(1).Data = block.InputPort(1).Data;


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?

Date Subject Author
Read Simulink queri
Vaibhav chidrewar
Read Re: Simulink queri

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.