NanSurf.zip

Make surface plot when X,Y,Z contain NaNs, taking care of NaN-discontinuities
ダウンロード: 514
更新 2019/10/9

ライセンスの表示

% NANSURF(X,Y,Z,varargin) - makes a trisurf plot of X,Y,Z choosing a triangulation
% that minimizes zigzag edges due to NaN's in Z. No data interpolation takes place.
%
% inputs : X,Y,Z 2D matrixes representing a surface
% outputs: ph plot handle
% trgList the chosen triangulation
%
% NANSURF(X,Y,Z) plots the colored parametric surface defined by matrix arguments.
% it works the same as trisurf but choosing triangulation according to NaN's in Z.
%
% NANSURF(X,Y,Z,'PropertyName',PropertyValue,...) plots the data
% stored in the vectors X and Y, according to Property/Value pairs:
%
% QuadEdgesOnly
% 1 : only show quad edges as in surf, hides the triangle edges
% 0 : (Default) plots all triangle edges (can be changed outside with 'edgecolor')
%
% trgExtend
% 1 : (Default) enable extending triangles to better reduce NaN-edge-aliasing
% in close to horizonal/vertical lines.
% 0 : maximizes nr of rendered triangles without creating/extending them
% should only be used to compare/debug triangulation
% DBGTrg
% 1 : debug plot showing which triangles are affected by NaNs
% 0 : (Default) no debug plots
%
% IDEA BEHIND:
% When a face, e.g. quadruple of vertexes in a meshgrid, contain 1 Nan, surf does not render it.
% Choose triangles to maximize # rendered ones, maintaining correct face orientation.
% Correct face orientation (based on gradient) improves color rendering.
%
% METHOD:
% (1) NaNsurf makes a triangulation which maximizes the number of valid triangles
% a valid triangle contains no NaNs. output: TRG, a list of L/R triangles based on NaNs in Z
% (2) TRG list from step (1) is used as input to trisurf / patch: trisurf(TRG,X,Y,Z)
%
% EXAMPLE:
% plotSpec = {'edgecolor','k','facecolor','interp'};
% NaNsurf(X,Y,Z,plotSpec{:});
%
% EXAMPLE:
% NaNsurf(X,Y,Z,plotSpec{:},'trgExtend',1,'DBGTrg',1);
%
% EXAMPLE:
% M = 22; N = 34;
% Mh = (M+1)/2; Nh = (N+1)/2;
% [X,Y] = meshgrid((1:N)-Nh,(1:M)-Mh);
% Rn = sqrt((X/Nh).^2+(Y/Mh).^2);
% Z = sin(3*pi*Rn)./(3*pi*Rn);
% Z(find(X.^2+Y.^2 > Mh^2)) = NaN;
% NaNsurf(X,Y,Z,'edgecolor','k','facecolor','interp')
% axis([-Mh Mh -Nh Nh -.5 1])
%
% rev.1.8, Massimo Ciacci, September 20, 2019

引用

Massimo Ciacci (2024). NanSurf.zip (https://www.mathworks.com/matlabcentral/fileexchange/46809-nansurf-zip), MATLAB Central File Exchange. 取得済み .

MATLAB リリースの互換性
作成: R2016b
すべてのリリースと互換性あり
プラットフォームの互換性
Windows macOS Linux
カテゴリ
Help Center および MATLAB AnswersSurface and Mesh Plots についてさらに検索
タグ タグを追加

Community Treasure Hunt

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

Start Hunting!
バージョン 公開済み リリース ノート
1.8.0.1

Tested with ML2016b, updated screenshot

1.8.0.0

- Added option 'QuadEdgesOnly'
- Added method reorder_XYZT_for_Surf_Symmetry for preprocessing surf data

1.7.0.0

a preview button would have been nice..

1.6.0.0

oops, had forgotten the zip file..

1.5.0.0

embedded one debug-plot function were it belongs
slightly edited help section
changed screen-shoot to a simpler one

1.4.0.0

Yet a little formatting of the help section.

1.3.0.0

Changed screenshot, improved help to NanBasedTriangulation and placefig.

1.2.0.0

some minor comment editing

1.1.0.0

typo

1.0.0.0