How to apply fit-function on variable

6 次查看(过去 30 天)
So I've got a fit done with cftool:
%% Fit: 'untitled fit 1'.
[xData, yData] = prepareCurveData( N, A );
% Set up fittype and options.
ft = fittype( 'poly6' );
% Fit model to data.
[fitresult, gof] = fit( xData, yData, ft );
% Plot fit with data.
figure( 'Name', 'untitled fit 1' );
h = plot( fitresult, xData, yData );
legend( h, 'A vs. N', 'untitled fit 1', 'Location', 'NorthEast', 'Interpreter', 'none' );
% Label axes
xlabel( 'N', 'Interpreter', 'none' );
ylabel( 'A', 'Interpreter', 'none' );
grid on
hold on
Now I want the fit-function to be applid on a variable, let's say y. Hence fit-function(y). For example if the fit-function would go like fit = m*x +n, I'd like to reform it to fit = m*y + n. Thanks in advance and appologies for the 3th question asked in such a short period of time.

采纳的回答

Aditya Patil
Aditya Patil 2020-7-16
You can pass the new data to the fitobject. See the example below,
x = sin(1:10)';
x2 = cos(1:10)';
y = (1:10)';
curve = fit(x, y, 'poly2');
y2 = curve(x2);
Here y2 is calculated from the function fit on x.
  1 个评论
Niklas Kurz
Niklas Kurz 2020-7-16
Thank you. I asked this question in a state of total inexperience. After dealing with Matlab daily its beauty is being more and more revealed.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Get Started with Curve Fitting Toolbox 的更多信息

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by