从样条拟合中获取y值

3
我使用MATLAB曲线拟合工具进行样条平滑拟合并创建了一个函数。我该如何访问Y拟合值,以便将它们输出到文件中?似乎我只看到了x值和fitresult中的所有系数。以下是MATLAB代码。谢谢!
function [fitresult, gof] = createFit(Freq, AmplNew)
%CREATEFIT(FREQ,AMPLNEW)
%  Create a fit.
%
%  Data for 'untitled fit 1' fit:
%      X Input : Freq
%      Y Output: AmplNew
%  Output:
%      fitresult : a fit object representing the fit.
%      gof : structure with goodness-of fit info.
%

%% Fit: 'untitled fit 1'.
[xData, yData] = prepareCurveData( Freq, AmplNew );

% Set up fittype and options.
ft = fittype( 'smoothingspline' );
opts = fitoptions( 'Method', 'SmoothingSpline' );
opts.SmoothingParam = 0.998;

% Fit model to data.
[fitresult, gof] = fit( xData, yData, ft, opts );
1个回答

1

只需使用feval

y = feval(fitresult,x); 

或者只是使用


y = fitresult(x); 

1
你也可以直接使用fitresult(x)。 - lhcgeneva

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接