Automatically fit grid spacing

7 ビュー (過去 30 日間)
Ingo Rück
Ingo Rück 2017 年 9 月 7 日
コメント済み: Ingo Rück 2017 年 9 月 7 日
Hello everyone,
I'm looking for a smart/fast way to automatically generate a fitting grid spacing. I have a set of x-y-z points that I plot with the meshgrid function as shown in the following code where x and y are vectors with the x/y values of the points. fitresult is a sfit generated by the curve fitting tool box.
tx=min(x):spacingX:max(x);
ty=min(y):spaxingY:max(y);
[xm,ym]=meshgrid(tx,ty);
zm=fitresult(xm,ym);
mesh(xm,ym,zm)
spacingX and spacingY are to be the automatically generated values for my grid spacing. So basically what I need is a code that takes a look at max(x)-min(x) and then decides what grid spacing would give an accurate fit.
For example I manually use a spacing of 0.001 for a range of min(x)=0.0194 : max(x)=0.2353. The y-values for the same data set range from min(y)=8.5928 : max(y)=119.5933, so using the same spacing is impossible.
Is there a matlab function or mathematical way to automatically give me a fitting grid spacing?
Thanks for your help!

採用された回答

KSSV
KSSV 2017 年 9 月 7 日
Note that either you have to provide grid spacing or number of points you want along a axes.....if you fix....grid spacing..number of points are decided. Else if you provide number of points grid spacing is decided.
%%Number of points given
x = linspace(min(x),max(x),N) ;
%%Grid spacing given
x = min(x):dx:max(x) ;
  1 件のコメント
Ingo Rück
Ingo Rück 2017 年 9 月 7 日
So I could basically say that N=2*length(x) to have the spacing somewhat depending on my data. That doesnt seem very consistent because some data sets have outliers that would stretch the grid and make the mesh less accurate..

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

その他の回答 (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