Getting Error ''Function 'subsindex' is not defined for values of class 'function_handle'."
1 回表示 (過去 30 日間)
古いコメントを表示
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 件のコメント
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
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.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Numerical Integration and Differential Equations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!