请帮我摆脱以下错误:
error: 'x' undefined near line 3 column 8
error: called from
conv_test at line 3 column 2
MAIN at line 17 column 1
error: evaluating argument list element number 1
error: called from
conv_test at line 3 column 2
MAIN at line 17 column 1
在 MAIN.m 内部,我只需致电:
result_g_p1 = conv_test(@g_p1);
我的 g_p1.m:
function endpoint = g_p1(x)
endpoint = -8/(x^3);
end
conv_test.m :
function conv_test_result = conv_test(g)
if (g(x) > 1) && (g(x) < 0) <--- Line 3
conv_test_result = fprintf('Convergent Test Result: The function is monotonically convergent! \n');
elseif (g(x) > -1) && (g(x) < 0)
conv_test_result = fprintf('Convergent Test Result: The function is oscillatory convergent! \n');
else (g(x) > 1)
conv_test_result = fprintf('Convergent Test Result: The function is divergent! \n');
end
end
我不知道为什么x
未定义,因为我明确地在g_p1
内传递了conv_test
。