Multiple trend-lines for one dataset
古いコメントを表示
Dear community users,
I have a question related to the usage of multiple trend-lines on one dataset. Suppose I have a scatter plot with the following data:
Y=[0 0.25 0.5 0.75 1 2 3 4 5 6 7 8 9 9.25 9.5 9.75 10];
X=1:length(Y);
p = polyfit(X,Y,1);
P = polyval(p,X);
scatter(X,Y)
hold on
plot(X,P)
When plotting this data, a clear 'shape' can be seen: the plot is composed of three distinct linear section. Obviously, the actual scatter data contains lots more data points, and also a less distinct 'bending point' within the graph, however a clear shape of three linear lines can be seen.
It is very easy to plot one trend-line, however this will be wrong, as can be seen in the above plot. I want to create three distinct linear trend-lines, which I can also do by manually altering the polyfit data. However, I have to process a lot of data, and not all sets are equal in dimensions, meaning that I have to alter it manually every step.
Is there a way for MATLAB to create multiple of such plots, based on the data? Which means that if I alter the data, the resulting trend-lines will be altered automatically?
Thanks in advance!
回答 (1 件)
Jackie Corbitt
2018 年 8 月 30 日
0 投票
This is also my question, would love input on this!
カテゴリ
ヘルプ センター および File Exchange で Scatter Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!