Function requires more input arguments to run?

I am new to MATLAB and i am running a function called 'delaySolve2.m' to solve for true infection data given infection measurements and a delay function for covid-19. But i get the following error code when i try to run it; "delaySolve2" requires more input arguments to run.
BELOW IS THE deleySolve2 functinon codes;
function [Exposure,shift,znum] = delaySolve2(Infection,Dist,varargin)
% this code gets a vector of reported Infection and a delay distribution
% (Dist) and provides the estimated exposure/true infection
p=inputParser;
addOptional(p,'Penalty',0.2,@isnumeric); %the penalty for variance in Exposure over time
parse(p,varargin{:});
alpha=p.Results.Penalty;
%Dist = totd;
%Dist = DelayEstimation2;
Dist=Dist/sum(Dist); %making sure Dist adds to 1
Dist(cumsum(Dist)==1 & Dist==0)=[]; % remove trailing zeros
ilen=numel(Infection);
czdist=cumsum(Dist==0); %counting early zeros
if max(czdist)>0
znum=czdist(Dist==max(Dist));
else
znum=0;
end
Dist=flip(Dist);
if ilen<1
Exposure=[];
shift=0;
else
drn=numel(Dist);
coeff=zeros(ilen,ilen+drn);
for i=1:ilen
coeff(i,i:i+drn-1)=Dist;
end
dropped=sum(coeff,1)==0;
coeff(:,dropped)=[];
%coeff(:,ilen+1:end)=[];
xlen=size(coeff,2);
pnl=eye(xlen);
pnl(2:end,1:end-1)=pnl(2:end,1:end-1)-eye(xlen-1);
pnl(1:end-1,2:end)=pnl(1:end-1,2:end)-eye(xlen-1);
pnl=pnl+eye(xlen);
pnl(1,1)=1;pnl(end,end)=1;
Ex=quadprog(coeff'*coeff+alpha*pnl,-coeff'*Infection',-eye(xlen),zeros(xlen,1));
Exposure=zeros(numel(Infection)+drn,1);
Exposure(1:numel(Ex))=Ex;
shift=drn;
end
end

2 Comments

@BRIAN KANJI: how are you defining and providing the input arguments when you call the function?
If you are just clicking the big green "Run" button, what values do you expect Infection and Dist to have?
i have been able to provide the inputs,i.e. Infection(the reported new covid cases in a time series format) & Dist(delay distribution) in the command window and calling this function in the command window. It has run without giving the previous error of "function requires more input arguments to run". But in the process of running, i get the following error; "Error using zeros
Requested 474x10000474 (35.3GB) array exceeds maximum array size preference (15.9GB). This might cause MATLAB to become unresponsive.
Error in delaySolve2 (line 29)
coeff=zeros(ilen,ilen+drn);"

Sign in to comment.

 Accepted Answer

Jan
Jan on 25 May 2021
While the actual code of the function does not matter, it is important to know, how you try to call it. If you use the green triangle in the editor, the function is called without input arguments. If you call it from another function or from the command window, what do you provide as input arguments?
This would be clear, if you post the complete error message, not just a part of it. Remember this for the future to support the readers in the forum.

4 Comments

i have been able to provide the inputs,i.e. Infection(the reported new covid cases in a time series format) & Dist(delay distribution) in the command window and calling this function in the command window. It has run without giving the previous error of "function requires more input arguments to run". But in the process of running, i get the following error;
"Error using zeros
Requested 474x10000474 (35.3GB) array exceeds maximum array size preference (15.9GB). This might cause MATLAB to become unresponsive.
Error in delaySolve2 (line 29)
coeff=zeros(ilen,ilen+drn);"
drn is the number of elements in the input Dist. This is larger than the available memory.
so how can i solve this?
Jan
Jan on 28 May 2021
Edited: Jan on 28 May 2021
You simply provide some data, which exceed the available RAM. Then the solution is trivial: Either install much more RAM, or reduce the size of the problem.

Sign in to comment.

More Answers (0)

Categories

Find more on Programming in Help Center and File Exchange

Asked:

on 25 May 2021

Edited:

Jan
on 28 May 2021

Community Treasure Hunt

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

Start Hunting!