How to make a function that uses a mathematical function as an input?
7 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Benjamin Memisevic
il 12 Mar 2019
Commentato: madhan ravi
il 13 Mar 2019
I want to create a function that takes two inputs
f(x) and x1
that I can put through the central finite differentiation formula;
y=(f(x1+h)-f(x1-h))/2h
where h is a constant
and the function on each side = f(x)
so for example;
f(x)=sin(x)
x1=2
y=sin(2+h)-sin(2-h)/2*h
I want to function input that i can subsititute into but I don't know how to go about it, I've looked at anonymous function, parameter and other documentation.
I just want a nudge in the right direction, not a complete answer if at all possible.
0 Commenti
Risposta accettata
madhan ravi
il 12 Mar 2019
f=@(x)sin(x);
6 Commenti
madhan ravi
il 13 Mar 2019
@Benjamin: Need not be sorry. You may find this link useful:https://in.mathworks.com/help/matlab/matlab_prog/anonymous-functions.html
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Number Theory in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!