Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
movavg Too many output arguments.

Subject: movavg Too many output arguments.

From: Ryan

Date: 2 Oct, 2012 03:51:07

Message: 1 of 3

Here is my code in its entirety:
data = xlsread('brent_1D.xlsx');


filename = 'SBUX.xls';
AllDates = xlsread(filename,'A1:A686')
Close = xlsread(filename,'B1:B686')
annualScaling = sqrt(250);
movavg(Close, 5, 20, 'e')
[Short, Long] = movavg(Close, 5, 20, 'e')


sharpes = nan(100,1);

for m = 1:100
    [~,~,~,sharpes(m)] = movavg(Close,5,20,'e');
end

[~,mxInd] = max(sharpes);
movavg(Close,1,mxInd,annualScaling)
 

Everything works fine up until this line:
    [~,~,~,sharpes(m)] = movavg(Close,5,20,'e');

I get the following error when I run the code through the debugger:
Debugging
1 sharpes = nan(100,1);
Error using movavg
Too many output arguments.

Error in Debugging (line 4)
    [~,~,~,sharpes(m)] = movavg(Close,5,20,'e');


I know the movavg function takes 4 arguments; I can’t tell what the problem is here. The Editor Window seems somewhat helpful for debugging, but it’s not helping me in the case.

Does anyone have any idea what’s going on here? Can someone please help me get this straightened out? Basically, I’ll following the example here:

http://www.mathworks.com/matlabcentral/fileexchange/37932-automated-trading-with-matlab-2012/content/html/Demo2_MA_Rule.html#2

Subject: movavg Too many output arguments.

From: dpb

Date: 2 Oct, 2012 04:54:28

Message: 2 of 3

On 10/1/2012 10:57 PM, TideMan wrote:
...

>>
>> Everything works fine up until this line:
>>
>> [~,~,~,sharpes(m)] = movavg(Close,5,20,'e');
>>
>> I get the following error when I run the code through the debugger:
>>
>> Debugging
>>
>> 1 sharpes = nan(100,1);
>>
>> Error using movavg
>>
>> Too many output arguments.
>>
>> Error in Debugging (line 4)
>>
>> [~,~,~,sharpes(m)] = movavg(Close,5,20,'e');
>>
>> I know the movavg function takes 4 arguments; I cant tell what
>> the problem is here. ...

 From the doc for MOVAVG()...

Syntax

[Short, Long] = movavg(Asset, Lead, Lag, Alpha)

The message says "Too many _output_ arguments"; not too many inputs...

You've coded for four (albeit three tossed, but still four positional)
outputs whereas the function returns only two...

--

Subject: movavg Too many output arguments.

From: Ryan

Date: 2 Oct, 2012 23:13:07

Message: 3 of 3

You are correct!! Thanks for pointing that out to me!!


dpb <none@non.net> wrote in message <k4ds22$dek$1@speranza.aioe.org>...
> On 10/1/2012 10:57 PM, TideMan wrote:
> ...
>
> >>
> >> Everything works fine up until this line:
> >>
> >> [~,~,~,sharpes(m)] = movavg(Close,5,20,'e');
> >>
> >> I get the following error when I run the code through the debugger:
> >>
> >> Debugging
> >>
> >> 1 sharpes = nan(100,1);
> >>
> >> Error using movavg
> >>
> >> Too many output arguments.
> >>
> >> Error in Debugging (line 4)
> >>
> >> [~,~,~,sharpes(m)] = movavg(Close,5,20,'e');
> >>
> >> I know the movavg function takes 4 arguments; I cant tell what
> >> the problem is here. ...
>
> From the doc for MOVAVG()...
>
> Syntax
>
> [Short, Long] = movavg(Asset, Lead, Lag, Alpha)
>
> The message says "Too many _output_ arguments"; not too many inputs...
>
> You've coded for four (albeit three tossed, but still four positional)
> outputs whereas the function returns only two...
>
> --

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us