How to replicate this graph

5 visualizaciones (últimos 30 días)
Jaime Salgado Salinas
Jaime Salgado Salinas el 25 de Nov. de 2021
Respondida: Shanmukha Voggu el 1 de Dic. de 2021
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 comentario
dpb
dpb el 25 de Nov. de 2021
Not much to that, look at the doc for plot for examples...you will need hold on

Iniciar sesión para comentar.

Respuestas (1)

Shanmukha Voggu
Shanmukha Voggu el 1 de Dic. de 2021
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.

Categorías

Más información sobre Interpolation en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by