Borrar filtros
Borrar filtros

Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

Not enough input arguments

2 visualizaciones (últimos 30 días)
Courtney
Courtney el 14 de Mzo. de 2013
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
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');

Respuestas (1)

Image Analyst
Image Analyst el 14 de Mzo. de 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).

La pregunta está cerrada.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by