主题:这个错误是怎么回事?matlab全局变量与函数
我定义了函数,就是牛顿法查找的函数
function ind=search(value)
global Dim_up
global tag_up
L=1;
R=Dim_up;
M=floor((L+R)/2);
while (L<=R)
if (value>tag_up(M))
L=M+1;
M=floor((L+R)/2);
elseif (value<tag_up(M))
R=M-1;
M=floor((L+R)/2);
elseif (value==tag_up(M))
ind=M;
return
end
end
在主程序里调用
ind1=search(value);
结果出错
Error in ==> search at 2
global Dim_up
??? Output argument "ind" (and maybe others) not assigned during
call to
"F:\Program Files\MATLAB\reading_notes\science 327_1621\search.m
(search)".
Error in ==> Untitled1 at 78
ind1=search(value);
end
function ind=search(value)
global Dim_up
global tag_up
L=1;
R=Dim_up;
M=floor((L+R)/2);
while (L<=R)
if (value>tag_up(M))
L=M+1;
M=floor((L+R)/2);
elseif (value<tag_up(M))
R=M-1;
M=floor((L+R)/2);
elseif (value==tag_up(M))
ind=M;
return
end
end
在主程序里调用
ind1=search(value);
结果出错
Error in ==> search at 2
global Dim_up
??? Output argument "ind" (and maybe others) not assigned during
call to
"F:\Program Files\MATLAB\reading_notes\science 327_1621\search.m
(search)".
Error in ==> Untitled1 at 78
ind1=search(value);
end