How to replicate this graph

8 次查看(过去 30 天)
I'm trying to replicate the attached graph. I am given a data set with 25 rows of x,y values.
These are the requirements for the curves:
Given a set of 25 data points, create a graph that shows five fitted curves where for each curve, 5/25 points are left out. Also on this graph, show the 25 points. This means that the five curves would be based on the following 5 data sets:
Curve Number
1 2 3 4 5
Curve Fitted on Points (respectively)
6-25, 1-5, 11-25, 1-10, 16-25, 1-15, 21-25, 1-20
Accuracy Check Points (respectively)
1-5, 6-10, 11-15, 16-20, 21-25
  1 个评论
dpb
dpb 2021-11-25
Not much to that, look at the doc for plot for examples...you will need hold on

请先登录,再进行评论。

回答(1 个)

Shanmukha Voggu
Shanmukha Voggu 2021-12-1
Hi Jaime,
I understood you want to plot the curves in addition to the points, this can be achieved by using multiple plot functions and having hold on statements between them.
Lets plot all 25 points, I am assuming x and y are 25x1 matrices
plot(x,y,'co');
Lets Truncate 5 points in the middle (exlude 6-10 points in the data for plotting one curve)
x1=[x(1:5);x(11:25)];
y1=[y(1:5);y(11:25)];
hold on; % retains plots in the current axes so that new plots added to the axes do not delete existing plots
f1=fit(x1,y1,'poly2'); % Quadratic polynomial curve, one can use other ways to fit as well
plot(f1); % plot the curve
Add plots of other curves as mentioned above
% can use plot functions here for other curves
% by changing the data as shown above
hold off; % removes the constraint that is imposed by "hold on"
You can refer to the documentations on hold on, hold off, plot and fit functions for further information.

类别

Help CenterFile Exchange 中查找有关 Fit Postprocessing 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by