我正在尝试拟合一些数据,但使用多项式我找不到好的解决方案。那么,我怎样才能画出一条像黑色的曲线(知道曲线的类型)?
figure('Units', 'pixels', 'Position', [100 100 500 375]);
hold on;
ydata_s = [1.0e-03 0.5804 0.3916 0.2234 0.1527 0.0697 0];
ydata_m = [0.2765 0.2760 0.2758 0.2757 0.2755 0.2754];
xdata_m = [1 2.5 5 10 50 100];
% Fit with a line.
coeffs = polyfit(xdata_m, ydata_m, 2)
% Define the range where we want the line
xFitting = (0:1:100);
yFitted = polyval(coeffs, xFitting);
hFit = line(xFitting, yFitted);
hE = errorbar(xdata_m, ydata_m, ydata_s);
set(hFit , ...
'Color' , [0 .2 .6] );
set(hE , ...
'LineStyle' , 'none' , ...
'Marker' , '.' , ...
'Color' , [.8 .3 .3] );
hTitle = title ('Precisione / Velocità');
hXLabel = xlabel('Campionamnto [%]');
hYLabel = ylabel('Funzione Obiettivo [€/P]');
xlim([0 100]);
hLegend = legend( ...
[hE, hFit], ...
'Data (\mu \pm \sigma)' , ...
'Fit (\it{x^3})' , ...
'location', 'NorthEast' );
set(gca,'XTick',[1 2.5 5 10 50 100]);