### Thread: Matlab programming problem - not enough input arguments

1. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Dec 2013
Posts
1
Rep Power
0

#### Matlab programming problem - not enough input arguments

Hi there, I am trying to model the gaia daisyworld hypothesis in MATLAB and I keep getting the error message not enough input arguments. I want the output to show each daisy area changing with time and affecting the luminosty value.

I am relatively new to MATLAB, any help would be greatly appreciated

Here is the code I have used:

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

%plot the results

figure(1)

plot(1:length,Ablackresults,'k-')

hold on;

plot(1:length,Awhiteresults,'y-')

hold on;

plot(1:length,Awhiteresults+Ablackresults,'g--')

xlabel('Time dimensions')

ylabel('Daisy Area')

legend('Black daisies','White daisies','Total area',2)

title('Daisy area versus time')

axis([1 length 0 1])

figure(2)

subplot(2,1,1)

plot(1:length,Temissionresults,'g-')

hold on;

plot(1:length,Temissionresults,'r--')

xlabel('Time dimensions')

ylabel('Temperature (K)')

legend('Daisyworld','Lifeless world',2)

title('Temperature of Daisyworld vs time')

axis tight;

hold on;

subplot(2,1,2)

plot(1:length,Apresults,'m--')

axis([1 length black white]);

xlabel('Time dimensions')

ylabel('Average albedo')

title('Planetary albedo vs time')
2. You forget to tell when you get this message and whether the line number or some additional info is attached to it.

If you get this message when calling this function - then show how do you call it.
3. also put the code in [CODE.][/CODE.] or something. (without the points)

It makes it easier to read...