function [fitresult, gof] = createFit(day, cases)
[xData, yData] = prepareCurveData( day, cases );
ft = fittype( 'exp1' );
opts = fitoptions( 'Method', 'NonlinearLeastSquares' );
opts.Display = 'Off';
opts.StartPoint = [28.0415018660604 0.202270403686444];
[fitresult, gof] = fit( xData, yData, ft, opts );
figure( 'Name', 'Exponential_Curve_Corona' );
subplot( 2, 1, 1 );
h = plot( fitresult, xData, yData );
legend( h, 'New Cases vs. day', 'Exponential_Curve_Corona', 'Location', 'Best', 'Interpreter', 'none' );
xlabel('day', 'Interpreter', 'none' );
ylabel('cases', 'Interpreter', 'none' );
xlim([min(xData) max(xData)])
grid on
subplot( 2, 1, 2 );
h = plot( fitresult, xData, yData, 'residuals' );
legend( h, 'Exponential_Curve_Corona - residuals', 'Zero Line', 'Location', 'Best', 'Interpreter', 'none' );
xlabel('day', 'Interpreter', 'none' );
ylabel('cases', 'Interpreter', 'none' );
xlim([min(xData) (max(xData)+0.1)])
grid on
end
0 件のコメント
サインインしてコメントする。