matlab - 从样条拟合中获取 y 值

标签 matlab curve-fitting spline

我使用 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 );

最佳答案

只需使用 feval :

y = feval(fitresult,x); 

或者只是使用

y = fitresult(x); 

关于matlab - 从样条拟合中获取 y 值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32751589/

相关文章:

c++ - 在 C++ 中使用 matio 时 Mat_Open 不工作

java - 从数据序列构建一阶马尔可夫链转移矩阵(Java,Matlab)

python - scipy.curve_fit() 返回多行

r - 如何将 spline() 插值的 x 范围限制为 dplyr 中的第一个和最后一个非 NA 值?

java - 是否-XX : parallelGCThreads = 8 relates to the number of Cores in relation to Amdahl's law?

matlab - 如何设置 Matlab waitbar 大小?

python - 线性拟合 python 错误

python - 将对数正态分布拟合到已经装箱的数据 python

c++ - 如何应用样条基矩阵?

python - 在python中,如何在绘图中用平滑的线连接点?