Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

need help fixing errors..

5 vues (au cours des 30 derniers jours)
Courtney
Courtney le 8 Mai 2013
Clôturé : MATLAB Answer Bot le 20 Août 2021
in the command window i typed: tradeoffp(0.5,0.6)
received error statement: Undefined function 'tradeoffp' for input arguments of type 'double'.
Code below:
function [Survival]=tradeoffp(X,Y)
% function [Survival]=tradeoff(X,Y)
% 'X' 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)
for j=1:101
% this is the survival equation considering resources and predators
Survival(X,Y,'uint8')=(X.*R(i))+((1-X).*R(i)).*(P(j)/(1+P(j)))-(Y.*P(j));
end
end;
figure(1);
plot3(R,P,Survival,'g');
grid on
title('tradeoffp')
xlabel('Resources')
ylabel('Predators')
zlabel('Survival');

Réponses (1)

Lisa Wu
Lisa Wu le 8 Mai 2013
What's the P(j)? Before using the varible P ,you need to initialize it, such as P = linspace(0,1,101); And feel confused about this line : (X,Y,'uint8')=(X.*R(i))+((1-X).*R(i)).*(P(j)/(1+P(j)))-(Y.*P(j));

Cette question est clôturée.

Community Treasure Hunt

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

Start Hunting!

Translated by