Info
This question is closed. Reopen it to edit or answer.
Not enough input arguments
1 view (last 30 days)
Show older comments
First attempt at ever writing a code with a friend. Our teacher has not taought us anything. Please help!
Not enough input arguments for line 17:
survival(X,Y)=(X.*R(i))+((1-X).*(R(i).*(0.5)/1+0.5))-(Y.*0.5);
whole matlab function is:
function [Survival]=tradeoff(X,Y)
% function [Survival,Predator,R]=tradeoff(a,r)
% 'a' should be a vector with varying numbers for different predator levels
% - one for the low end of the range considered, the other the high end
% There are one output.
% Survival - the males' survival
% X is alpha value a is between 0 and 1.
R=linspace(0,10,100);
% the above lets us consider 100 different males,
% resources varying between the lowest 0 and highest
% 10 value given as inputs
for i=1:length(R)
% this is the survival equation considering resources and predators
survival(X,Y)=(X.*R(i))+((1-X).*(R(i).*(0.5)/1+0.5))-(Y.*0.5);
end;
figure(1);
plot(R,survival,'g');
title('tradeoff')
xlabel('Resources')
ylabel('Survival');
0 Comments
Answers (1)
Image Analyst
on 14 Mar 2013
Instead of
for i=1:length(R)
% this is the survival equation considering resources and predators
survival(X,Y)=(X.*R(i))+((1-X).*(R(i).*(0.5)/1+0.5))-(Y.*0.5);
end;
Just have this:
% this is the survival equation considering resources and predators
survival = (X.*R)+((1-X).*(R.*(0.5)/1+0.5))-(Y.*0.5);
You don't use (x,y) after survival because it's an array. And you don't use (i) after R because you can just use R and do the whole array in one shot (no for loop needed).
0 Comments
This question is closed.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!