Surface fitting for a matrix

19 ビュー (過去 30 日間)
Keyla Gonzalez
Keyla Gonzalez 2020 年 5 月 7 日
コメント済み: Ameer Hamza 2020 年 5 月 8 日
Hi,
Do you know how can I obtain surface fit (polynomial) for a matrix of size 20x20. I notice that in the curve fitting toolbox you need to enter your data as X and Y; however I'm not how to use it with a matrix of that size.
I also used imagesc to visualize my values however im not sure if I can do something with the image.

回答 (1 件)

Ameer Hamza
Ameer Hamza 2020 年 5 月 7 日
If you just have the matrix, then you can use the row and column number as the x and y variables. Try this example
M = ((1:10)+(1:10).').^2;
[X, Y] = meshgrid(1:size(M,2), 1:size(M,1));
fit_model = fit([X(:) Y(:)], M(:), 'poly43');
plot(fit_model, [X(:) Y(:)], M(:))
  2 件のコメント
Keyla Gonzalez
Keyla Gonzalez 2020 年 5 月 8 日
Thank you Ameer, it worked perfectly.
Ameer Hamza
Ameer Hamza 2020 年 5 月 8 日
I am glad to be of help.

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

カテゴリ

Help Center および File ExchangeGet Started with Curve Fitting Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by