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 commentaires

akshatsood
akshatsood le 23 Jan 2024
Modifié(e) : akshatsood le 23 Jan 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 le 23 Jan 2024
Hi Akshatsood thank you for your reply, yes I attached a data set in the excel file.

Connectez-vous pour commenter.

 Réponse acceptée

Walter Roberson
Walter Roberson le 23 Jan 2024
Modifié(e) : Walter Roberson le 23 Jan 2024

0 votes

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 commentaires

Abdallah Magour
Abdallah Magour le 24 Jan 2024
Hi Walter, yes I used polyfit and polyval but it did not give the same result.
I was looking for a fitting function that output the equation shown in the figure directly.
Walter Roberson
Walter Roberson le 24 Jan 2024
There is no fitting function that will output the equation shown in the figure directly.
When I test, polyfit() gives exactly the same results as that fit.
Abdallah Magour
Abdallah Magour le 24 Jan 2024
Okay, can I ask how did you manage to get past the NaN in the data when using polyfit?
The data I have contains NaN in severla locations, maybe this is creating an issue for me.
I have atached the complete data set in the excel file.
Abdallah Magour
Abdallah Magour le 24 Jan 2024
I found this methods to overpass the NaNs and it works.
Now polyfit works fine! Thanks for your help
maxt = Tausfitting1(:,11);
length = T
idx = isnan(maxt);
fit1 = polyfit(length(~idx),maxt(~idx),8);
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 le 24 Jan 2024
Hi Sam,
This is perfect,exactly what I needed!! Thank you very much.
Works much better than what I have.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Get Started with Curve Fitting Toolbox dans Centre d'aide et File Exchange

Produits

Version

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by