Info

此问题已关闭。 请重新打开它进行编辑或回答。

need help fixing errors..

1 次查看(过去 30 天)
Courtney
Courtney 2013-5-8
关闭: MATLAB Answer Bot 2021-8-20
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');

回答(1 个)

Lisa Wu
Lisa Wu 2013-5-8
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!

Translated by