measuring local slope from scatter plot data and replotting this value
3 views (last 30 days)
Show older comments
Hi,
I want to make a plot of
Ln[dLn(c)/dLn(x)] vs Ln(x)
where I have measured c at different irregularly spaced x and the c value varies quite a lot so that the differential should change quite a lot from point to point and some fitting between a few points is probably a better way to represent the differential at any value. I suppose a window between +-3 points or so is probably a better way to represent the gradient. Does anyone have any idea how to plot this data?
Thanks!
Just to add to this - I've tried to use the graph fitting app but it's not working and im not sure why. I've tried plotting Ln(c) vs Ln(x) then fitting exp^W(x) to a plot of Ln(c) vs Ln(x)
0 Comments
Answers (1)
Pavan Sahith
on 19 Oct 2023
Hello,
I understand you have some irregularly spaced data, and you are trying for some fitting within a ±3 points, a 7-element window to represent the gradient in a better way.
As a workaround you can try using “smoothdata” function.
Please refer to the following example code which uses “smoothdata” with some sample data and sample method.
x = 1:100;
A = cos(2*pi*0.05*x+2*pi*rand) + 0.5*randn(1,100);
% using movmean method in a window of 7 elements
C = smoothdata(A,"movmean",7);
plot(x,C)
Please refer to this MathWorks documentation links to know more about
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!