Undefined function or variable "Horz_average_l"
1 次查看(过去 30 天)
显示 更早的评论
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".
0 个评论
采纳的回答
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
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);
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Assumptions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!