Undefined function or variable "Horz_average_l"

1 visualizzazione (ultimi 30 giorni)
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".

Risposta accettata

Thorsten
Thorsten il 28 Nov 2014
Modificato: Thorsten il 28 Nov 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 Commenti
Thorsten
Thorsten il 28 Nov 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 il 2 Dic 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!

Accedi per commentare.

Più risposte (0)

Tag

Non è stata ancora inserito alcun tag.

Community Treasure Hunt

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

Start Hunting!

Translated by