Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

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


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

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

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?


Date Subject Author
2/11/09
Read Simulink queri
Vaibhav chidrewar
2/17/13
Read Re: Simulink queri
Tiger

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

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.