Info

This question is closed. Reopen it to edit or answer.

need help fixing errors..

2 views (last 30 days)
Courtney
Courtney on 8 May 2013
Closed: MATLAB Answer Bot on 20 Aug 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');

Answers (1)

Lisa Wu
Lisa Wu on 8 May 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));

Community Treasure Hunt

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

Start Hunting!