Borrar filtros
Borrar filtros

How to apply fit-function on variable

6 visualizaciones (últimos 30 días)
Niklas Kurz
Niklas Kurz el 20 de Jun. de 2020
Comentada: Niklas Kurz el 16 de Jul. de 2020
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.

Respuesta aceptada

Aditya Patil
Aditya Patil el 16 de Jul. de 2020
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 comentario
Niklas Kurz
Niklas Kurz el 16 de Jul. de 2020
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.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Get Started with Curve Fitting Toolbox en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by