Undefined function or variable "Horz_average_l"

1 visualización (últimos 30 días)
Tan Phan
Tan Phan el 28 de Nov. de 2014
Comentada: Tan Phan el 2 de Dic. de 2014
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".

Respuesta aceptada

Thorsten
Thorsten el 28 de Nov. de 2014
Editada: Thorsten el 28 de Nov. de 2014
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 comentarios
Thorsten
Thorsten el 28 de Nov. de 2014
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 el 2 de Dic. de 2014
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!

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Aún no se han introducido etiquetas.

Community Treasure Hunt

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

Start Hunting!

Translated by