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