MATLAB Answers

Problem with movavg "Not enough input arguments."

2 views (last 30 days)
Bruno on 28 Feb 2014
Answered: Bruno on 28 Feb 2014
Hello I am trying to calculate movavg as:
I have the following:
Error using movavg (line 7) Not enough input arguments.
So if I try:
I have:
Error using movavg (line 8) This function only supports exponential moving averages
So it only works if I use the following:
...BUT I want simple moving averages not exponential!!
This is strange since the syntax of the function is the following:
movavg(Asset, Lead, Lag, Alpha) [Short, Long] = movavg(Asset, Lead, Lag, Alpha)
Anybody can help me?
  1 Comment
Bruno on 28 Feb 2014
I am wondering if I changed the original function using the files prepared by Stuart Kazola
This is the code I have in movavg
function [lead,lag] = movavg(P,M,N,type) %#codegen % moving average, exponentially weighted.
%% % Copyright 2010, The MathWorks, Inc. % All rights reserved. if type ~= 'e' error('MOVAVG:TYPE','This function only supports exponential moving averages') end
L = length(P);
lead = zeros(size(P)); lag = lead;
ws = 2/(M+1); wl = 2/(N+1);
lead(1) = P(1); lag(1) = P(1);
% The for loop approach (slow for small-medium sized data series) for i = 2:L lead(i) = lead(i-1) + ws*(P(i) - lead(i-1)); lag(i) = lag(i-1) + wl*(P(i) - lag(i-1)); end

Sign in to comment.

Accepted Answer

Bruno on 28 Feb 2014
RESOLVED... the movavg.m prepared by Stuart Kazola conflicts with movavg.m Financial Toolbox R2013b

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by