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: level 2 m-file s function for frame based signal
Replies: 1   Last Post: May 11, 2013 11:00 PM

Advanced Search

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

Posts: 1
Registered: 5/8/13
level 2 m-file s function for frame based signal
Posted: May 8, 2013 7:26 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

i am not getting output for the below code so pls do suggest me what all to correct in it

function adapt_lmsnew(block)

setup(block);
%endfunction

function setup(block)

%% Register dialog parameter: LMS step size
block.NumDialogPrms = 1;
block.DialogPrmsTunable = {'Tunable'};
% block.DialogPrm(1).Name = 'StepSize';
% block.DialogPrm(1).DataTypeId = 0;

%% Regieste number of input and output ports
block.NumInputPorts = 2;
block.NumOutputPorts = 3;

%% Setup functional port properties to dynamically
%% inherited.
block.SetPreCompInpPortInfoToDynamic;
block.SetPreCompOutPortInfoToDynamic;

block.InputPort(1).Complexity = 'Real';
block.InputPort(1).DataTypeId = 0;
block.InputPort(1).SamplingMode = 'frame';
block.InputPort(1).dimensions = [32 2];
block.sampletimes = [32/8000 0];

block.InputPort(2).Complexity = 'Real';
block.InputPort(2).DataTypeId = 0;
block.InputPort(2).SamplingMode = 'frame';
block.InputPort(2).dimensions = [32 2];

block.OutputPort(1).Complexity = 'Real';
block.OutputPort(1).DataTypeId = 0;
block.OutputPort(1).SamplingMode = 'frame';
block.OutputPort(1).dimensions = [32 2];

block.OutputPort(2).Complexity = 'Real';
block.OutputPort(2).DataTypeId = 0;
block.OutputPort(2).SamplingMode = 'frame';
block.OutputPort(2).dimensions = [32 2];

block.OutputPort(3).Complexity = 'Real';
block.OutputPort(3).DataTypeId = 0;
block.OutputPort(3).SamplingMode = 'frame';
block.OutputPort(3).dimensions = [32 2];
block.sampletimes = [32/8000 0];

%% Set the block simStateCompliance to default (i.e., same as a built-in block)
block.SimStateCompliance = 'DefaultSimState';

%% Register methods
block.RegBlockMethod('CheckParameters', @CheckPrms);
block.RegBlockMethod('ProcessParameters', @ProcessPrms);
block.RegBlockMethod('PostPropagationSetup', @DoPostPropSetup);
block.RegBlockMethod('Start', @Start);
block.RegBlockMethod('Outputs', @Outputs);

% %% Block runs on TLC in accelerator mode.
block.SetAccelRunOnTLC(false);

%endfunction

function CheckPrms(block)
mu = block.DialogPrm(1).Data;

if mu <= 0 || mu > 1
error(message('simdemos:adapt_lms:stepSize'));
end
%endfunction


function DoPostPropSetup(block)
%% Setup Dwork
N = 32; %% Filter length
block.NumDworks = 2;
block.Dwork(1).Name = 'X'; %% u[n],...,u[n-31]
block.Dwork(1).Dimensions = N;
block.Dwork(1).DatatypeID = 0;
block.Dwork(1).Complexity = 'Real';
block.Dwork(1).UsedAsDiscState = true;


block.Dwork(2).Name = 'H'; %% Filter coefficients
block.Dwork(2).Dimensions = N;
block.Dwork(2).DatatypeID = 0;
block.Dwork(2).Complexity = 'Real';
block.Dwork(2).UsedAsDiscState = true;

%% Register all tunable parameters as runtime parameters.
block.AutoRegRuntimePrms;

%endfunction

function ProcessPrms(block)

block.AutoUpdateRuntimePrms;

%endfunction

function Start(block)

%% Initialize Dwork
block.Dwork(1).Data = zeros(1,32);
block.Dwork(2).Data = zeros(1,32);
%
%endfunction

function Outputs(block)


mu = block.RuntimePrm(1).Data;
N = 32;

u = block.InputPort(1).Data;
d = block.InputPort(2).Data;

X = block.Dwork(1).Data;
H = block.Dwork(2).Data;

%%
%% H^(n+1)[i] = H^(n)[i]+mu*(d(n)-y(n))*u(n-i)
%%
X(2:N) = X(1:N-1);
X(1) = u;

y = X'*H;
% y = y+H*u;
e = d-y;

H = H+mu*e*X;

block.Dwork(1).Data = X;
block.Dwork(2).Data = H;

block.OutputPort(1).Data = y;
block.OutputPort(2).Data = e;
block.OutputPort(3).Data = H;



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.