필터 지우기
필터 지우기

call function, not enough input argument error

조회 수: 2 (최근 30일)
tevzia
tevzia 2013년 7월 2일
Hello, I try to call function in my main code. However, It says "Not enough input argument" when i call it. here is my code, Could youplease help me what argument i forget to add
%
function [ breedingpopulation ] = calcbreedingpop(nperiods, nstands, area, CVOL, DVOL, breedingpop)
%UNTITLED4 Summary of this function goes here
% Detailed explanation goes here
harvsched=unidrnd(nperiods+1,1,nstands)-1;
harvvol=zeros(nperiods,1);
for istand = 1:nstands
harvper=harvsched(istand);
if harvper >0
harvvol(harvper) = harvvol(harvper) + area(istand) * (CVOL(istand,harvper)+ DVOL(istand,harvper));
end
end
totvol = sum (harvvol);
penalty = calcPenalty(harvvol,harvgoal,underpweight,overpweight,nperiods, npv, npvgoal, unpvweight, onpvweight);
breedingpop(i).time=time;
breedingpop(i).penalty=penalty;
breedingpop(i).sched=harvsched;
bestsched=harvsched
end
% code
  댓글 수: 2
the cyclist
the cyclist 2013년 7월 2일
How do you call this function from your main code?
What is the full error message you get?
tevzia
tevzia 2013년 7월 2일
I call it like this
%
breedingpopulation = calcbreedingpop(nperiods, nstands, area, CVOL, DVOL, breedingpop)
%
Error using breedingpop (line 6) Not enough input arguments.
Error in genetic_code (line 28) breedingpopulation = calcbreedingpop(nperiods, nstands, area, CVOL, DVOL, breedingpop)
There is a nested fucntion (calcPenalty) I wasnt sure if i set other function as an argument. like:
%
function [ breedingpopulation ] = calcbreedingpop(nbreeding, nperiods, nstands, calcPenalty, breedingpop)
%
but this time calcPenalty functiojn gives an error (" Error using calcPenalty (line 4) Not enough input arguments.")

댓글을 달려면 로그인하십시오.

답변 (1개)

the cyclist
the cyclist 2013년 7월 2일
No, you should not put the nested functions in the argument list.
In the calling function, is breedingpop a function or a variable? I think the problem is that when you call
breedingpopulation = calcbreedingpop(nperiods, nstands, area, CVOL, DVOL, breedingpop)
your code believes that breedingpop is a function that is itself expecting some inputs.

카테고리

Help CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by