Borrar filtros
Borrar filtros

Diff (f(x+h)-f(h))/h

3 visualizaciones (últimos 30 días)
lola lola
lola lola el 8 de Abr. de 2017
Comentada: Star Strider el 8 de Abr. de 2017
if to the question: diffresensial (f(x+h)-f(h))/h for h>0. if you can help to formula?
  3 comentarios
lola lola
lola lola el 8 de Abr. de 2017
yes geoff, The derivative of a function f can be approximated by f(x+h)-f(x)/h. for h>0. Write an m-file to define the function derive that takes as input a function f and two :h and x. On return is the approximation for the derivative f'(x), computed using the formula above.
can you help answer this question?
John D'Errico
John D'Errico el 8 de Abr. de 2017
But this is your homework. We can help you to fix a problem, but you need to try it, as otherwise, you don't learn. So make an effort, instead of just giving up. Show where you are having a problem. Then you are more likely to get help here.

Iniciar sesión para comentar.

Respuestas (1)

Star Strider
Star Strider el 8 de Abr. de 2017
The code is exactly as you wrote it for the actual calculation. To construct the function, see the documentation on Function Basics. You will have to test for ‘h>0’ (although the practical lower limit is 1E-8).
  2 comentarios
lola lola
lola lola el 8 de Abr. de 2017
Can you help to write the script?
Star Strider
Star Strider el 8 de Abr. de 2017
I cannot without completely giving you the solution. It is a very straightforward problem.
First, experiment with your equation alone and see how it works with various functions. So for example, if you are using your equation to take the numerical derivative of sin, your equation should return close to the same output as the cos of the same angle. (It will not be exactly the same, so close enough is good enough.)
When you are certain your equation is working, then read about functions in the link I gave you, and put it in a function file. Remember to test for h>0 in your function, write an error message if it is not. Read the documentation for the error function to help you with that.
Also, the first few lines of your function should describe your function, what it does, and how to use it, using comment lines (starting with % in each line).

Iniciar sesión para comentar.

Categorías

Más información sobre Variables en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by