Why it says undefined variable x2

function [x2] = secant(f, x0, x1)
while true
x2 =f(x1)*(x2-x0)/f(x0)+x1;
if x1 == x2
return;
end
x0 = x1;
x1 = x2;
end
end

回答(1 个)

James Tursa
James Tursa 2018-9-26
You have x2 appearing on the right hand side of your first assignment, before it has been defined.

3 个评论

thank you so much
Hazel
Hazel 2023-9-9
编辑:Hazel 2023-9-9
Hello @Dandan Lv, have you figured out this x2 equation that does not contain x2 on the RHS?

请先登录,再进行评论。

类别

帮助中心File Exchange 中查找有关 Get Started with MATLAB 的更多信息

提问:

2018-9-26

评论:

2023-9-9

Community Treasure Hunt

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

Start Hunting!

Translated by