Getting Error ''Function 'subsindex' is not defined for values of class 'function_handle'."

1 回表示 (過去 30 日間)
Will Sheppard
Will Sheppard 2018 年 12 月 11 日
コメント済み: Steven Lord 2018 年 12 月 11 日
Please help, I am getting the above error when I am trying to input a function handle into another function. My code calling the function is as follows : a,b,c, and d are defined and have values. I do not understand what is wrong here. Thanks in advance.
  2 件のコメント
madhan ravi
madhan ravi 2018 年 12 月 11 日
upload your code picture won't help
Steven Lord
Steven Lord 2018 年 12 月 11 日
BTW your if statement, in the absence of any limitations on a and d, is not generally true.
Let a = -1, b = 1, c = 0, d = 0.5. d is greater than a, but the plot created by the code below clearly crosses y = 0 near x = 1 and x = -1.
>> f = @(x) -cos(x)+0.5;
>> fplot(f)
fzero confirms that f has a zero.
>> r = fzero(f, 0)
Let's plot the zero and check.
>> hold on
>> plot(r, f(r), 'ro')
>> yline(0);

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

回答 (1 件)

Walter Roberson
Walter Roberson 2018 年 12 月 11 日
you define Newton_Raphson as a variable , the result of ismember . But then you have
Newton_Raphson(y)
which asks to index the array using the function handle y as the index .
I have no idea what your intent is.

カテゴリ

Help Center および File ExchangeNumerical Integration and Differential Equations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by