Hi, I have a x vs y text data file. I want to find the maximum and minimum value of first derivative of the y w.r.t x and store the corresponding x and y values. Can anyone tell me the MATLAB code for that? Thanks in advance!

1 次查看(过去 30 天)
This is the code I have written:
>> a = load('xaxisfig7line1'); >> y = a(:,2); >> x = a(1,:); >> dy = diff(y)./diff(x);
Next How do I find the corresponding x and y values for a particular value of dy and store it in a file? Thanks, Anuradha

回答(1 个)

Star Strider
Star Strider 2016-5-20
Use the gradient function, not diff to calculate the derivative. It is the same size as the argument vector. This assumes that your ‘x’ values are evenly-spaced. See the documentation for details.
If the ‘x’ vector are not evenly-spaced (or acceptably close), consider using the polyfit, polyder, and polyval functions. The documentation for those functions will tell you how to use them. Use the lowest-order polynomial that will provide an acceptable fit to your data. Usually you can do this with at most a 7th-order polynomial.

类别

Help CenterFile Exchange 中查找有关 Get Started with MATLAB 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by