フィルターのクリア

How to get curve fitting equation

4 ビュー (過去 30 日間)
Abdallah Magour
Abdallah Magour 2024 年 1 月 23 日
コメント済み: Abdallah Magour 2024 年 1 月 24 日
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 件のコメント
akshatsood
akshatsood 2024 年 1 月 23 日
編集済み: akshatsood 2024 年 1 月 23 日
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 2024 年 1 月 23 日
Hi Akshatsood thank you for your reply, yes I attached a data set in the excel file.

サインインしてコメントする。

採用された回答

Walter Roberson
Walter Roberson 2024 年 1 月 23 日
編集済み: Walter Roberson 2024 年 1 月 23 日
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 件のコメント
Sam Chak
Sam Chak 2024 年 1 月 24 日
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 2024 年 1 月 24 日
Hi Sam,
This is perfect,exactly what I needed!! Thank you very much.
Works much better than what I have.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeInterpolation についてさらに検索

製品


リリース

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by