Hello,
i got one function to classifiy a Number N.
The classifikation depends on a maximal Number n_max and on the boundaries of the classes KG0,… .
Also it should depend, how much classes i define. So if i define just 4 boundaries KG0-KG3 case 6 should act, because we have 4 boundaries+ 2 standard input numbers N and n_max. If define just 3 boundaries, KG0-KG2 , case 5 should act.
The ClassNumber is ultimately the class in which i put Number N.
Case 5 doesnt work, when i define everything except KG3. Matlab throws: Undefined function or variable 'KG3'. It shall not happen if i go in case 5 isnt it?
Thank you for help.
function [ClassNumber] = Classification(N, n_max, KG0, KG1, KG2, KG3)
switch nargin
case 6
if (KG2<N/n_max) && (N/n_max<=KG3)
ClassNumber=3;
return
elseif (KG1<N/n_max) && (N/n_max<=KG2)
ClassNumber=2;
return
elseif (KG0<=N/n_max) && (N/n_max<=KG1)
ClassNumber=1;
return
end
case 5
if (KG1<N/n_max) && (N/n_max<=KG2)
ClassNumber=2;
return
elseif (KG0<=N/n_max) && (N/n_max<=KG1)
ClassNumber=1;
return
end
end
end
Best Answer