필터 지우기
필터 지우기

Undefined function or variable "Horz_average_l"

조회 수: 1 (최근 30일)
Tan Phan
Tan Phan 2014년 11월 28일
댓글: Tan Phan 2014년 12월 2일
I read many answers for question: Undefined function or variable in forum, and check with my code, but i have not repaired that error. Can u see to help me?
function[Horz_average_l,Horz_average_r]= Horz_avg(Start,End,side) Sum =0; ITERATIONS = 200;
syms i j side Start End
switch side case 1
for j=0: (ITERATIONS-1),
for i=Start(j): (Start(j)+End(j))/2-1
Sum = Sum + BWPic(i,j);
end
Horz_average_l(j)= Sum/((End(j) - Start(j))/2); %Left side only */
Sum = 0;
end
case 2
for j=0:(ITERATIONS-1)
for i=((Start(j)+End(j))/2) : (End(j)-1)
i = i +1;
Sum = Sum + BWPic(i,j);
end
Horz_average_r(j)= Sum/((End(j) - Start(j))/2); % Right side only
Sum = 0;
end
end
for j = 0 : (ITERATIONS-4)
if Horz_average_l(j+1) >=Horz_average_l(j) && Horz_average_l(j+2) < Horz_average_l(j+1) && Horz_average_l(j+3) >= Horz_average_l(j+2)
end
end
error in the last if
Undefined function or variable "Horz_average_l".

채택된 답변

Thorsten
Thorsten 2014년 11월 28일
편집: Thorsten 2014년 11월 28일
The last if seems to have no body.
Please format all your code.
Why do you use
syms i j side Start End
Where is PWPic defined?
And what is the function exactly supposed to do?
  댓글 수: 3
Thorsten
Thorsten 2014년 11월 28일
I still do not understand why you need to use symbolic variables i j side Start End
How are Start and End defined?
What is the function supposed to do?
You have defined Start and End as arguments of your function. So you have to pass them when you call the function. Otherwise you get the "Not enough input arguments."
So you should have defined Start and End outside your function and then call is like
mystart = ... % whatever your variable is defined
myend = ...
[hl hr] = Horz_avg(mystart,myend,1);
Tan Phan
Tan Phan 2014년 12월 2일
Thanks Mr Thorsten!
I try your way and it is better. really do not need
syms i j side Start End
I declare my variables in global and it is recognized!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Assumptions에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by