Daisyworld function error, insufficient arguments

1 view (last 30 days)
Hi I am hoping to use a matlab model of Daisyworld (the Text of which I have posted below) but I keep getting the same error: 'function error insufficient input arguments' and gives no line indication for the error and little more info. The model is from a PhD paper's appendix and is widely used (Wittwer 2005). I've tried everything I can think of (limited though that is I'm afraid) manually adding an 'upper' and 'lower' values for example and playing around with their values and nothing! Can anyone help me with this please? it would be greatly appreciated.
Here's the code:
function dworldD(lower,upper)
S = 1000;
q = 15;
black = .25;
bare = .5;
white = .75;
death = .1;
lowgrowthK = 278;
highgrowthK = 313;
startarea = 0.01;
number = 100;
% Calculate the number of time steps (numba per 3 billion years)
length = (upper-lower)*number;
if length~=round(length)
length = round(length);
j = abs(length);
else j = abs(length);
end
if length>0
jump = (upper*S-lower*S)/(length-1);
E(1,1) = lower*S;
for a=2:length
E(a,1)=E((a-1),1)+jump;
end
end
% allows insolation to be decreasing throughout Daisyworld
if length<0
jump = (lower*S-upper*S)/(j+1);
E(1,1) = lower*S;
for a = 2:j
E(a,1) = E((a-1),1)-jump;
end
end
if length<0
length = abs(length);
end
SB = 5.669*10^-8;
%initializes the daisy area to 1% to allow growth to start
Ablack = startarea;
Awhite = startarea;
%begin iterations for each time step
for a=1:length
%calculates area of bareground & planet albedo
Abare = 1-Ablack-Awhite;
Ap = Abare*bare + Awhite*white + Ablack*black;
%calculate emission & local temps
Temission = ((E(a,1)/SB)*(1-Ap))^0.25;
Trock = ((E(a,1)/SB)*(1-bare))^0.25;
Tblack = q*(Ap-black)+Temission;
Twhite = q*(Ap-white)+Temission;
%calculate daisy growth - define growth & add previous daisy cover
betab=beta(lowgrowthK,highgrowthK,Tblack);
betaw=beta(lowgrowthK,highgrowthK,Twhite);
growthb = Ablack*(betab*Abare-death);
growthw = Awhite*(betaw*Abare-death);
Ablack = Ablack+growthb;
Awhite = Awhite+growthw;
%ensure that there is no negative/too much area
if Ablack < startarea
Ablack = startarea;
end
if Ablack > 1
Ablack = 1;
end
if Awhite < startarea
Awhite = startarea;
end
if Awhite > 1
Awhite = 1;
end
%store results
Temissionresults(1,a)=Temission;
Ablackresults(1,a)=Ablack;
Awhiteresults(1,a)=Awhite;
Trockresults(1,a)=Trock;
Apresults(1,a)=Ap;
growthbresults(1,a)=growthb;
growthwresults(1,a)=growthw;
end

Answers (2)

Geoff Hayes
Geoff Hayes on 22 Nov 2015
pi - how are you calling this function? Because if you are just running the program though the MATLAB editor (i.e. by pressing the green button) or calling the function from the command line as
dworldD
then the error message
Error using dworldD (line 13)
Not enough input arguments.
makes sense as I (and you) are not supplying any input parameters. I am not sure what the input parameters should be, but you must supply them. Something like
dworldD(1.42, 6.78);
However, when I do this, then I observe another error message
Error using beta
Too many input arguments.
which tells me that my version of beta within R2014a does not require the three input parameters that are being passed as
betab=beta(lowgrowthK,highgrowthK,Tblack);
betaw=beta(lowgrowthK,highgrowthK,Twhite);
  2 Comments
pi piper
pi piper on 22 Nov 2015
Hi Geoff, thankyou very much for getting back to me. Yes I essentially tried what you suggested first off by manually assigning
upper=0.6
lower=1.2
and got the same issue as you - too many input arguments.
Checking mathworks it says Beta(Z,W) so yes perhaps there are too many inputs. Have you got any suggestions as to what to do?
Geoff Hayes
Geoff Hayes on 22 Nov 2015
I went looking through some of the older (and online) MATLAB documentation but couldn't find the definition for a version of the beta function that takes three input parameters (even going back to pre-R2006a). So I don't know what you should do next short of contacting the author of the code.
I did see http://www.mathworks.com/matlabcentral/fileexchange/35008-generation-of-random-variates/content/beta.m on the FileExchange which seems to indicate that betainc can be used instead...but that may lead to other problems.
Perhaps someone else on the forum knows of why beta, at one time, took three parameters.

Sign in to comment.


shanza shakoor
shanza shakoor on 11 May 2020
Had you solve this issue ?? Now i am facing the same issue . Can you help me.

Community Treasure Hunt

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

Start Hunting!