Getting Error ''Function 'subsindex' is not defined for values of class 'function_handle'."
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Steven Lord
le 11 Déc 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);
Réponses (1)
Walter Roberson
le 11 Déc 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 commentaires
Voir également
Catégories
En savoir plus sur Numerical Integration and Differential Equations dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!