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: using using variables in built in function
Replies: 4   Last Post: May 3, 2012 10:27 AM

Advanced Search

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

Posts: 32
Registered: 3/2/10
using using variables in built in function
Posted: May 2, 2012 9:25 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Hi I would like to define this function:

rsi=@(x)rsindex(close, x);

in order to use the optimization toolbox.

The problem is that rsindex (that is a built in function in Matlab) is the following:

function rsi = rsindex(closep, nperiods)
switch nargin
case 1
nperiods = 14;

case 2
if numel(nperiods) ~= 1 || mod(nperiods, 1) ~= 0
error('Ftseries:rsindex:NPERIODSMustBeScalar', ...
'NPERIODS must be a scalar integer.');

elseif nperiods > length(closep)
error('Ftseries:rsindex:NPERIODSTooLarge1', ...
'NPERIODS is too large for the number of data points.');

........... etc ......

So the error is: NPERIODS must be a scalar integer.

I would like to know what is the best thing to do in this case... Should I rewrite the built in function? Is this possibile? What else?

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.