- Smooth noisy data using smoothdata https://www.mathworks.com/help/matlab/ref/smoothdata.html
- Fit using ‘polyfit’ https://www.mathworks.com/help/matlab/ref/polyfit.html
- Use cftool for flexible interface where you can interactively fit curves and surfaces to data and view plots. (Requires Curve Fitting Toolbox) https://www.mathworks.com/help/curvefit/curvefitter-app.html. You can also specify your own custom equation to fit your data.
How to create a smooth curve through data points?
    132 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    Inteeskimo
 el 5 de Dic. de 2017
  
    
    
    
    
    Editada: MathWorks Support Team
    
 el 6 de Mzo. de 2023
            I have a basic plot as follows. x = [0 0.2 0.4 0.8 1.2 1.6 2.0]; y = [0 0.155 0.240 0.328 0.450 0.582 0.692];
plot(x,y,'x','MarkerEdgeColor','black') grid on; xlabel('Protein standard concentration (µg/µl)'); ylabel('Average absorbance value');
Now I want a smooth curve to go through the data points. Any suggestions?
0 comentarios
Respuesta aceptada
  Star Strider
      
      
 el 5 de Dic. de 2017
        
      Editada: MathWorks Support Team
    
 el 6 de Mzo. de 2023
  
      There are various ways you can achieve this:  
Below is an example of using 'polyfit'. A linear fit is probably appropriate, unless you have a specific equation you want to fit to it:
x = [0 0.2 0.4 0.8 1.2 1.6 2.0];
y = [0 0.155 0.240 0.328 0.450 0.582 0.692];
p = polyfit(x, y, 1);
v = polyval(p, x);
figure(1)
plot(x,y,'x','MarkerEdgeColor','black')
hold on
plot(x, v)
hold off
grid on;
xlabel('Protein standard concentration (µg/µl)');
0 comentarios
Más respuestas (2)
  John D'Errico
      
      
 el 5 de Dic. de 2017
        The question is, do you have knowledge of this process? Well, everybody knows something about their data, about the underlying system that produced it.
For example, do you know the curve passes through (0,0)? Very often, when point is supplied as (0,0), you know the curve passes through that point.
Is the bump down at the bottom real, or is it just noise?
Thus, the smoothest curve I can imagine is this:
S = x(:)\y(:)
S =
      0.36704
plot(x,y,'o',x,S*x,'r-')

What I don't know is if the lack of fit is significant, or just data noise.
Of course, if the point at zero is not important, then a simple linear fit with a constant makes sense.
P1 = polyfit(x,y,1); plot(x,y,'o',x,P1(1)*x+P1(2),'r-')

Alternatively, we might consider a cubic polynomial, with no constant term.
C = (x(:).^(1:4))\y(:);
xint = linspace(0,2,100)';
plot(x,y,'o',xint,(xint.^(1:4))*C,'r-')

Thus,
y = C(1)*x + C(2)*x^2 + C(3)*x^3 + C(4)*x^4
That forces the curve to pass through zero, has a bump at the bottom end, etc. But it has a little tweak near the top.
spl = spline(x,y);
plot(x,y,'o',xint,ppval(spl,xint),'r-')

What matters is what you know about the curve, what you know about the data.
  MHZ
 el 5 de Dic. de 2017
        One option is cftool Another option is polyfit function Third option is smooth function
0 comentarios
Ver también
Categorías
				Más información sobre Get Started with Curve Fitting Toolbox en Help Center y File Exchange.
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



