필터 지우기
필터 지우기

How to apply fit-function on variable

조회 수: 6 (최근 30일)
Niklas Kurz
Niklas Kurz 2020년 6월 20일
댓글: Niklas Kurz 2020년 7월 16일
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