Getting Error ''Function 'subsindex' is not defined for values of class 'function_handle'."
1 view (last 30 days)
Show older comments
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 Comments
Steven Lord
on 11 Dec 2018
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);
Answers (1)
Walter Roberson
on 11 Dec 2018
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 Comments
See Also
Categories
Find more on Numerical Integration and Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!