how to solve this error,??? Input argument "alpha" is undefined. Error in ==> newvod3RL at 6 alphaINT = (real(alpha)>0) .* ceil(real(alpha)) + ...

function out = vod3RL(t, in, alpha)
% function out = vod3RL(t, in, alpha)
% Variable order derivative, Riemann-Liouville definition, variant 3.
% Duarte Valrio, 2009.
alphaINT = (real(alpha)>0) .* ceil(real(alpha)) + ...
( (real(alpha)==0) & (imag(alpha)~=0) ); % number of differentiations to perform
alphaRES = alpha - alphaINT; % residue of alphaINT with negative real part only
% negative differentiation (i.e. integration) performed
out = zeros(size(t));
for k = 2 : length(t) % the first integral is always 0, since no time elapsed, hence no need to make k = 1...
tau = t(1:k);
integrand = (t(k) - tau).^(-alphaRES(k - (1:k) + 1) - 1) ./ gamma(-alphaRES(k - (1:k) + 1)) .* in(1:k);
if any(~isfinite(integrand)) % eliminate eventual inf and nan points
integrand(find(isinf(integrand))) = 0;
integrand(find(isnan(integrand))) = 0;
end
integrand(1) = 2*integrand(1); % this is to handle steps properly with Caputo's definition
% (otherwise the first point only has half the influence and the result comes halved all the way to the end)
out(k) = sum( (integrand(1:end-1)+integrand(2:end))/2 .* (tau(2:end)-tau(1:end-1)) );
end
% necessary differentiations performed
while 1
if sum(alphaINT) == 0, break, end % exit condition
temp = diff([0; out]) ./ [t(2)-t(1); diff(t)]; % this is to handle steps properly
out = out.*(alphaINT==0) + temp.*(alphaINT~=0);
alphaINT = (alphaINT-1) .* (alphaINT~=0); % take away one integration
end

 Accepted Answer

naeem - how are you calling this function, vod3RL? Are you supplying three inputs as
result = vod3RL(t,in,alpha);
where t, in, and alpha are local variables that have been initialized to something? The error message is telling you that you haven't passed in (at least) the third input parameter, and so you must define it (and the other two) and pass them as arguments/inputs to the function.

2 Comments

i am supplying three inputs as
alpha=0.9
in=0.5
t=1
and now i am getting an error of
??? Attempted to access t(2); index out of bounds because numel(t)=1.
Error in ==> vod1RL at 30
temp = diff([0; out]) ./ [t(2)-t(1); diff(t)]; % this is to handle steps properly
Given the code, t must be a vector and not a scalar. For example,
t = 1:10;

Sign in to comment.

More Answers (0)

Asked:

on 27 Nov 2014

Commented:

on 30 Nov 2014

Community Treasure Hunt

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

Start Hunting!