Scripting a derivation - integration from XY values

Hello everyone,
I am working on a project and my last thing is calculate a value from an analysed results.
I have M - T values at constant H. And try to do that (I gave below) step by step calculation at MATLAB but I can not imagine my scriptting.
  1. Plot M(T,H) (H = Constant) -> I have already M - T values (H constant)
  2. Perform numerical differantiation of the function M(T,H) with respect to T. -> I used polyfit(T,M,2)
  3. Plot dM(T,H)/dT (T = constant) from dM(T,H)/dT (H = constant) -> I did not realize it.
  4. Numerical integration of the function dm(T,H)/dT (T=constant) with respect to H. -> Also this one.
OK, I generate a function by using polyfit for M and T values but I did not understand other steps. Can anyone help me?
Thank you!

4 Comments

polyfit isn't differentiation, it's fitting a polynomial (in your example a quadratic) to the data.
I know, but first of all I try to generate a fuction from my XY values to differantiate and integrate it.
You don't necessarily need to create a function. This introduces error, because the approximation will have lack of fit to your data.
For example, you can use the gradient function to differentiate a data series.
You can use trapz or cumtrapz to integrate a data series.
It depends on how much noise is is the data, and how good of an approximation is your curve fit. You may easily be introducing more error into the problem just by your use of a polynomial fit. Without seeing the data and the fit you choose, I would need to say that you need to consider which option is correct.
Alright, I see. But what if I want to integrate my values according to summution approximation.
with this equation ?

Sign in to comment.

Answers (0)

Asked:

on 11 Jul 2020

Commented:

on 11 Jul 2020

Community Treasure Hunt

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

Start Hunting!