how to calculate a derivative
Show older comments
can some one guide me how to calculate a derivative and integration in matlab . can you please give a little example.
1 Comment
Jan
on 26 Feb 2012
Symbolically or numerically?
Accepted Answer
More Answers (3)
Magdalena Glinska
on 16 Nov 2020
f = @(x) sin(x);
second_derivative_f = matlabFunction(diff(sym(f)));
Hamza saeed khan
on 24 Nov 2020
syms x
f = x;
diff(f,x)
why this code give me error as;
>>Error in diff (line 1)
syms x
4 Comments
Dheeresh agarwal
on 22 Dec 2020
diff(f,1)
Walter Roberson
on 22 Dec 2020
You probably do not have the symbolic toolbox installed or licensed.
Also, you accidentally named your script diff.m which is going to conflict with calling diff() to differentiate.
belvia
on 12 May 2025
même chez moi le diff là ne donne pas
Steven Lord
on 12 May 2025
"même chez moi le diff là ne donne pas"
Please show us the exact code you're running and all the text displayed in red in the Command Window (and if there are any warning messages displayed in orange, please show us those too) that you see when you run that code. The exact text may be useful and/or necessary to determine what's going on and how to avoid the warning and/or error.
Achimsettythanmay
on 14 Nov 2022
Edited: Walter Roberson
on 15 Nov 2022
syms x real
f = 1/x
int(f,1,2) % integration
diff(f) %differentiation
Categories
Find more on Special Values in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!