How do I integrate a combined function?
Mostra commenti meno recenti
For my own script, I need to combine several functions and finally calculate the integral of the lot. To simplify it, I made a simple problem with the same error:
"Input function must return 'double' or 'single' values. Found 'function_handle'.". The actual code is much larger, has more parameters and because of the size of the function I prefer multiple seperate functions.
a = @(x) x;
b = @(x) a*cos(x);
C = integral(@(x) b,0,5);
I understand the @(x) is not the right way for using the integral-function, because it should have double or single values, as stated in the error. But in what way should I handle this problem to get the right answer out this simple example? (ans = -5,51...)
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Mathematics in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!