Borrar filtros
Borrar filtros

How to get curve fitting equation

4 visualizaciones (últimos 30 días)
Abdallah Magour
Abdallah Magour el 23 de En. de 2024
Comentada: Abdallah Magour el 24 de En. de 2024
Is there a way I can get the equation shwon in the figure or in the basic fitting window? The 8th degree polynimial.
I want to get this equation through a code line not through the graph tools, I also need it in the exact same form.(Including x)
I will repeiat this for a large number of plots or x and y data directly if possible.
Please ignore the red line at the bottom.
  2 comentarios
akshatsood
akshatsood el 23 de En. de 2024
Editada: akshatsood el 23 de En. de 2024
Could you please provide me with the data needed to replicate the issue on my end, allowing me to assist you better?
Abdallah Magour
Abdallah Magour el 23 de En. de 2024
Hi Akshatsood thank you for your reply, yes I attached a data set in the excel file.

Iniciar sesión para comentar.

Respuesta aceptada

Walter Roberson
Walter Roberson el 23 de En. de 2024
Editada: Walter Roberson el 23 de En. de 2024
You would use polyfit
For a degree 8 polynomial, you would probably want to use the centering and scaling, by requesting that S and mu also be returned from polyfit()
To evaluate points at the fitted polynomial, see polyval
  6 comentarios
Sam Chak
Sam Chak el 24 de En. de 2024
The data is not the same as what is shown in the image above. However, you can remove the NaN values by utilizing the isnan() function.
T = readtable("Data from a similar graph.xlsx", VariableNamingRule="preserve")
T = 17×2 table
x-axis y-axis _______ __________ -19.88 0.00013017 -14.923 NaN -9.8295 0.00034944 -4.7163 0.00010504 0.42855 0.00010026 5.4723 0.00010318 10.501 0.00010048 15.349 0.00010017 20.066 0.00010005 25.012 0.00010006 29.942 0.00010015 34.999 0.00010153 39.906 0.00010248 44.89 0.00010044 49.954 0.00010016 54.913 0.0001014
x = T{:,1};
y = T{:,2}; % contains NaN
data= [x, y];
%% Omit row contains NaN
data_clean = data(~isnan(data(:, 2)), :)
data_clean = 16×2
-19.8796 0.0001 -9.8295 0.0003 -4.7163 0.0001 0.4286 0.0001 5.4723 0.0001 10.5011 0.0001 15.3487 0.0001 20.0662 0.0001 25.0120 0.0001 29.9422 0.0001
%% Extract from clean data
x_clean = data(:,1);
y_clean = data(:,2);
plot(x_clean, y_clean, '-o'), grid on
Abdallah Magour
Abdallah Magour el 24 de En. de 2024
Hi Sam,
This is perfect,exactly what I needed!! Thank you very much.
Works much better than what I have.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Interpolation en Help Center y File Exchange.

Productos


Versión

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by