フィルターのクリア

How to fit a surface to 3D dta points

31 ビュー (過去 30 日間)
Mos_bad
Mos_bad 2018 年 9 月 14 日
コメント済み: Stephen23 2018 年 9 月 14 日
Please find the attached. I want to fit a surface to show the trends of the 3d data points but I got an error that 'Z must be a matrix, not a scalar or vector'.

回答 (2 件)

Stephen23
Stephen23 2018 年 9 月 14 日
編集済み: Stephen23 2018 年 9 月 14 日
Your data are scattered, not gridded:
surf only plots gridded data. To use surf you will either have to
  1. interpolate the values onto a grid, or
  2. fit a curve get gridded values and plot them.
Another option would be to use a Delaunay triangulation to plot the scattered data directly:
trisurf(delaunay(IM,Z50),IM,Z50,MnXdisp)
Gives:
This blog gives an nice explanation of options for scattered data:
  2 件のコメント
Mos_bad
Mos_bad 2018 年 9 月 14 日
the data abe been like these first : Z50_ = linspace(0,20,20); IM_ = linspace(0.0025,1.2,20); [IM, Z50] = meshgrid(IM_, Z50_); Therefore, at each IM or Z50, there are 10 data from MnXdisp data set. I wonder if it is possible to fit 20 curves and then plot a surface.
Stephen23
Stephen23 2018 年 9 月 14 日
@Mos_bad: well, the data you gave us might have been gridded at some point in history, but is now missing many data points. If you have data then of course you can fit curves to it (if that has any meaning depends on the data and what it represents).

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


KSSV
KSSV 2018 年 9 月 14 日
編集済み: KSSV 2018 年 9 月 14 日
% Unstructred data plot
dt = delaunayTriangulation(IM,Z50) ;
t = dt.ConnectivityList ;
p = dt.Points ;
figure (1);
plot3(IM,Z50,MnXdisp,'b*');
hold on;
trisurf(t,p(:,1),p(:,2),MnXdisp')
title('unstructured')
% structured plot
x = IM ; y = Z50 ; z = MnXdisp ;
N = 50 ;
xi = linspace(min(x),max(x),N) ;
yi = linspace(min(y),max(y),N) ;
[X,Y] = meshgrid(xi,yi) ;
Z = griddata(x,y,z,X,Y) ;
figure (2);
plot3(IM,Z50,MnXdisp,'b*');
hold on;
surf(X,Y,Z)
title('structured')

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by