Does Error Message Depend on Whether or Not Function is Executed Inside Try/Catch?
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
This call to diff resolves to symbolic diff
syms s
diff(@(s) 1/(s+1),s)
which diff(@(s) 1/(s+1),s)
I guess the parser sees that the first input is an anonymous function, for which there is no diff method, then goes to second argument, decides to call sym->diff, and that works becuase the function_handle can be promoted to a sym expression.
This call to diff throws an error.
B = BasicClass;
try
diff(BasicClass,s)
catch ME
ME.message
end
I don't understand the error message, because based on the pervious result I would have expected sym->diff to be called, and then the error message would be something like 'can't convert BasicClass object to sym' or something like that. I've read over the doc pages, and still don't understand why it doesn't try to call sym->diff and instead looks for a BasicClass method called diff.
As expected, which doesn't find anything for that call.
which diff(BasicClass,s)
But, making the same call at the command prompt generates a different error:
diff(BasicClass,s)
Why is this error different than that generated inside the try/catch, and to which diff function is this error message referring?
2 commentaires
Réponse acceptée
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Number Theory 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!