How to replicate this graph
6 views (last 30 days)
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:
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
Shanmukha Voggu on 1 Dec 2021
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
Lets Truncate 5 points in the middle (exlude 6-10 points in the data for plotting one curve)
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"