Function requires more input arguments to run?
Mostra commenti meno recenti
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 Commenti
Stephen23
il 25 Mag 2021
@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?
BRIAN KANJI
il 27 Mag 2021
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Programming in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!