Function in Matlab that calculates the nth derivative

I want the code for a function that calculate the nth derivative without using built in function like "diff".

9 Comments

It is not possible to do anything without builtin functions. If this is your homework question you should ask a specific question. You can find guidelines for posting homework on this forum here.
@Rik we can use built in functions but not "diff"
All of my functions are constants, so the nth derivative, (for n >= 1) is zero.
nthderiv = 0;
@John I don't get your point
If you're a complete beginner I'd suggest checking out the Matlab Onramp course, which covers all the basics you need to get started. If you've done that and are happy with basic functions, arrays and the syntax, then the next step would be to have a look at the wikipedia page for numerical differentiation. The first section on finite differences is likely what you need.
After that, have a go at writing a function which estimates a derivative. If you have a specific question about Matlab or its applications then post that, but posting a relatively advanced homework question without even trying doesn't look great.
Thank you so much for your help
There was no point to my comment, but your question has no meaningful answer. If you cannot use a tool like diff, then this is homework. Homework is there for you to solve, not for us to do for you.

Sign in to comment.

Answers (0)

Categories

Asked:

on 5 Jan 2021

Commented:

on 5 Jan 2021

Community Treasure Hunt

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

Start Hunting!