Finding a trendline from a scatter plot
102 views (last 30 days)
Show older comments
Hello
Dear All
I need to find a trendline for a scatter plot(s) in Matlab. Unfortunately, my scatter plot(s) does not show a nice trend, or relationship between between my X's and Y. I want to know if Matlab is able to give me the best possible trendline that can be fit for that scatter plot or at least I try to fit different types of curves. Excel is able to fit a trendline (Liner, Logarithmic, Polynomial, and etc) having any scatter plot, but it seems Matlab cannot do that--at least using polyfit(X,Y,n) having n=1,2,...
attached is one of my scatter plots picture.
Thank you
0 Comments
Accepted Answer
ME
on 9 Dec 2019
MATLAB can do this if you make your scatter plot and then in the figure window go to "Tools -> Basic Fitting". That will then allow you to draw a bunch of different data fits onto your diagram, output the residuals, output the formulae, etc.
I'm sure there is probably a way to call this all programatically but I don't know of it.
I know there are also fitting tools in some of the MATLAB licensed toolboxes, but I don't currently have access to any of those so I can't really be much help on those.
Perhaps somebody else might be able to help with the gaps here!
0 Comments
More Answers (0)
See Also
Categories
Find more on Scatter Plots 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!