Surface fit doesnt cover all datapoints

1 回表示 (過去 30 日間)
Jesús Gutiérrez
Jesús Gutiérrez 2020 年 6 月 23 日
コメント済み: Jesús Gutiérrez 2020 年 6 月 24 日
I am triying to plot a surface response with some input points from a parametric study with the following code:
[xData,yData,zData] = prepareSurfaceData(x,y,z);
ft = 'cubicinterp';
[fitresult,gof] = fit([xData,yData], zData, ft, 'Normalize', 'on');
[X,Y] = meshgrid(x(1):0.1:xData(end),y(1):0.1:y(end));
Z = fitresult(X,Y);
surf(X,Y,Z,'EdgeColor','texturemap');
The problem is that the surface fitted doesn't cover all original points x,y,z (red balls in figures), it stops in a given x () value. I am fitting ten different surfaces with the same x and y data points but different z and all have the same problem.
  2 件のコメント
dpb
dpb 2020 年 6 月 23 日
Attach at least one of the datasets -- nobody can reproduce anything easily.
It would appear that the problem is probably that your [X,Y] vectors don't span the space; you use limits from the first and last elements in an input array, but those apparently aren't necessarilyh the minimum nor maximum points in the datasets.
Jesús Gutiérrez
Jesús Gutiérrez 2020 年 6 月 23 日
Thanks for the response! Just attached two datasets I'm using for the surface. (I know there are very few datapoints for a proper surface fit but its all I have available).

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

採用された回答

John D'Errico
John D'Errico 2020 年 6 月 23 日
編集済み: John D'Errico 2020 年 6 月 23 日
load dataset1
x
x =
20 30 40 50 20 30 50 40 50 60 40 50 60 20 30 50 60 70 30 40 50
Why am I surprised that x(1) and x(end) do not contain all the data?
x(end)
ans =
50
max(x)
ans =
70
How did you display the data?
[X,Y] = meshgrid(x(1):0.1:xData(end),y(1):0.1:y(end));
Of course, this line of code does not even use x(end), but xData(end).
[xData,yData,zData] = prepareSurfaceData(x,y,diff_fpant_1_max);
>> xData
xData =
20
30
40
50
20
30
50
40
50
60
40
50
60
20
30
50
60
70
30
40
50
However, does prepareSurfaceData actually perform a sort of your data? It might be a good idea to look at that.
I would suggest you are jumping to conclusions without actually looking at what some of that code does. That would alsys seem a dangerous thing to do.
  1 件のコメント
Jesús Gutiérrez
Jesús Gutiérrez 2020 年 6 月 24 日
Thanks for your help, I wasn't sure where to start finding the problem. I got this code from the internet but I didn't understand it well... I just introduced min(x), max(x), min(y), max (y) as arguments instead of (1) and (end) and now i get a surface that at least covers all input points.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCurve Fitting Toolbox についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by