Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.


condor
Posts:
32
Registered:
3/2/10


using using variables in built in function
Posted:
May 2, 2012 9:25 PM


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.'); end
........... 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?



