3D - Surface Response Plot - Surface of best fit

39 ビュー (過去 30 日間)
Muhammad Hamza Saloojee
Muhammad Hamza Saloojee 2020 年 10 月 30 日
コメント済み: Ameer Hamza 2020 年 10 月 31 日
I'm having trouble plotting a curve/surface of best fit through data points. I have z - matrix of 9 data points, which correspend to different combinations of values from an x-vector of 3 and a y-vector of 3. I have managed to plot a surface plot which uses interpolation and fits a curve through the data. Instead of this, I would like to plot a curve of best fit through the data points using a low order polynomial instead.
Assistance would be greatly appreciated.
This is a plot of what I have so far.

採用された回答

Ameer Hamza
Ameer Hamza 2020 年 10 月 30 日
編集済み: Ameer Hamza 2020 年 10 月 30 日
If you have a curve fitting toolbox, you can use fit(): https://www.mathworks.com/help/curvefit/fit.html function with fitype chosen from polyij as given here: https://www.mathworks.com/help/curvefit/list-of-library-models-for-curve-and-surface-fitting.html#btbcxlm. For example
x; % x-values 9x1
y; % y-values 9x1
z; % z-values 9x1
X = [x y];
Y = z;
fitted_model = fit(X, Y, 'poly22')
If you don't have the toolbox, you can still use mldivide (\) to do least square curve-fitting. For example, suppose you want to fit following model
Then you can do something like this
X = [ones(size(x)) x y x.^2 y.^2 x.*y];
Y = z;
a = X\Y;
  11 件のコメント
Muhammad Hamza Saloojee
Muhammad Hamza Saloojee 2020 年 10 月 30 日
This is perfect.
Thank you so much for the assistance!
Much appreciated.
Ameer Hamza
Ameer Hamza 2020 年 10 月 31 日
I am glad to be of help!

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by