필터 지우기
필터 지우기

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 CenterFile Exchange에서 Interpolation에 대해 자세히 알아보기

제품


릴리스

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by