Calling a function in bisect.m

1 回表示 (過去 30 日間)
Rashi Jain
Rashi Jain 2020 年 11 月 16 日
コメント済み: Rashi Jain 2020 年 11 月 16 日
I am not sure what is going wrong here, but I created a function @f. I am trying to implement it in bisect to find theta. When I am inside bisect, it says that there is an unrecognized function ot variable 'f'. Only that the function or variable is very much in the workspace when I am inside the function f.
Here is the complete code. hw7p2.m is the executable file.

採用された回答

Geoff Hayes
Geoff Hayes 2020 年 11 月 16 日
Rashi - try removing (in the hw7p2.m file) the @ in front of the function handle that you are passing into the bisect function.
theta = bisect(f, pi/2, pi); % <--- pass f and not @f
Also, consider removing feval from your bisect function and just do
fxl = fun(xl);
fxm = fun(xm);
  1 件のコメント
Rashi Jain
Rashi Jain 2020 年 11 月 16 日
Thank you so much. That solved it.

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by