tag:www.mathworks.com,2005:/matlabcentral/fileexchange/feedMATLAB Central File Exchangeicon.pnglogo.pngMATLAB Central - File Exchange - category:"Graphics" category:"3-D Visualization"User-contributed code library2014-12-26T01:51:02-05:002001100tag:www.mathworks.com,2005:FileInfo/132002006-12-01T14:09:09Z2014-12-25T23:41:01Z3D Polar PlotPlots 3d polar data with polar axis and polar grid<p>Polarplot3d produces surface, mesh, wireframe and contour plots for three dimensional polar data. A labeled polar axis is drawn at a fixed height or it can follow the surface contour at maximum radius. A polar grid can also be drawn on top of the surface.
<br />This function is based on polar3d by J De Freitas, file exchange ID 7656. </p>
<p>The input parameters are a matrix of magnitudes, Zp, and a list of property,value pairs that modify the default plot behavior. Each column of Zp contains information along a single half-meridian and each row gives height values along a circular arc. By default Zp is assumed to be increasing in radius down each column and increasing in angle (counter-clockwise) along each row. The default plot is drawn over a full circle of unit radius.</p>
<p>'RadialRange' and 'AngularRange' properties can be used to specify the upper and lower angular and radial values over which the data is plotted. The relative ordering of the angular and radial range vectors is used to determine the angular and radial direction sense of the rows and columns of Zp. Alternatively a vector can be specified giving the locations of each row or column.</p>
<p>The polar axis can be placed at the minimum, maximum or mean value of Zp at the largest radius, at the top or bottom of the plot box, at a user specified location, or it can follow the surface at the perimeter of the data. The polar axis tick mark spacing can be adjusted with the 'TickSpacing' property.</p>
<p>The default polar axis orientation is that zero degrees is along the +X axis and increasing angles are counter-clockwise. The 'PolarDirection' property can be used to change this to a compass style plot with zero degrees along the +Y axis and increasing angles going clockwise around the pole.</p>
<p>Default surface coloring is according to the values in Zp. This can be changed by supplying a matrix the same size as Zp as the value of the 'ColorData' property.</p>
<p>A scaling parameter can be specified to interpolate the data onto a finer or coarser mesh. The output Cartesian data is returned in three matrices.</p>
<p>The example plot in the screenshot was produced with the following commands.</p>
<p> [t,r] = meshgrid(linspace(0,2*pi,361),linspace(-4,4,101));
<br /> [x,y] = pol2cart(t,r);
<br /> P = peaks(x,y); % peaks function on a polar grid</p>
<p> % draw 3d polar plot
<br /> figure('Color','white','NumberTitle','off','Name','PolarPlot3d v4.3');
<br /> polarplot3d(P,'PlotType','surfn','PolarGrid',{4 24},'TickSpacing',8,...
<br /> 'AngularRange',[30 270]*pi/180,'RadialRange',[.8 4],...
<br /> 'RadLabels',3,'RadLabelLocation',{180 'max'},'RadLabelColor','red');</p>
<p> % set plot attributes
<br /> set(gca,'DataAspectRatio',[1 1 10],'View',[-12,38],...
<br /> 'Xlim',[-4.5 4.5],'Xtick',[-4 -2 0 2 4],...
<br /> 'Ylim',[-4.5 4.5],'Ytick',[-4 -2 0 2 4]);
<br /> title('polarplot3d example');</p>
<p>The zip file contains the polarplot3d function and an m-file with example plots.</p>Ken Garrardhttp://www.mathworks.com/matlabcentral/fileexchange/authors/18049MATLAB 7.5 (R2007b)7656falsetag:www.mathworks.com,2005:FileInfo/95192006-01-05T10:25:43Z2014-12-25T23:07:43ZColor coded 3D scatterplotProduces a 3D scatterplot of XYZ data with varying colors<p>A 3D scatter plot of a Cartesian data set is drawn. The data points are sorted by color and plot3 is called once for each group of points that map to the same color. This reduces execution time significantly for large data sets. By default the points are colored according to their distance from the XY plane. This can changed with the 'ColorData' property. Additionally the upper and lower limits of the color range can be specified. This is useful for creating a series of plots with the same coloring.
<br />The example plot is produced by the following code.</p>
<p> figure('color','white');
<br /> [x,y,z] = peaks(101);
<br /> c = gradient(z);
<br /> k = hypot(x,y)<3;
<br /> plot3k({x(k) y(k) z(k)}, ...
<br /> 'Plottype','stem','FontSize',12, ...
<br /> 'ColorData',c(k),'ColorRange',[-0.5 0.5],'Marker',{'o',2}, ...
<br /> 'Labels',{'Peaks','Radius','','Intensity','Lux'});</p>
<p>Plot3k is based on plot3c by Uli Theune.</p>Ken Garrardhttp://www.mathworks.com/matlabcentral/fileexchange/authors/18049MATLAB 7.7 (R2008b)5735falsetag:www.mathworks.com,2005:FileInfo/466372014-05-16T11:40:09Z2014-12-25T07:00:22ZA Simple Finite Volume Solver for MatlabA simple yet general purpose FVM solver for transient convection diffusion PDE<p>A simple Finite volume tool
<br />This code is the result of the efforts of a chemical/petroleum engineer to develop a simple tool to solve the general form of convection-diffusion equation:
<br />α∂ϕ/∂t+∇.(uϕ)+∇.(−D∇ϕ)+βϕ=γ
<br />on simple uniform mesh over 1D, 1D axisymmetric (radial), 2D, 2D axisymmetric (cylindrical), and 3D domains.
<br />The code accepts Dirichlet, Neumann, and Robin boundary conditions (which can be achieved by changing a, b, and c in the following equation) on a whole or part of a boundary:
<br />a∇ϕ.n+bϕ=c.
<br />It also accepts periodic boundary conditions.
<br />The main purpose of this code is to serve as a handy tool for those who try to play with mathematical models, solve the model numerically in 1D, compare it to analytical solutions, and extend their numerical code to 2D and 3D with the minimum number of modifications in the 1D code.
<br />The discretizaion schemes include
<br /> * central difference
<br /> * upwind scheme for convective terms
<br /> * TVD schemes for convective terms</p>
<p>A short html document is available to get you started. Simply type
<br />showdemo FVTdemo
<br />after downloading and extracting the code.</p>
<p>A few calculus functions (divergence, gradient, etc) and averaging techniques (arithmetic average, harmonic average, etc) are available, which can be helpful specially for solving nonlinear or coupled equations or implementing explicit schemes.</p>
<p>I have used the code to solve coupled nonlinear systems of PDE. You can find some of them in the Examples/advanced folder.</p>
<p>There are a few functions in the 'PhysicalProperties' folder for the calculation of the physical properties of fluids. Some of them are not mine, which is specified inside the file.</p>
<p>I'll try to update the documents regularly, in the github repository. Please give me your feedback/questions by writing a comment in my weblog: <<a href="http://fvt.simulkade.com/">http://fvt.simulkade.com/</a>>
<br />Special thanks: I vastly benefited from the ideas behind Fipy <<a href="http://www.ctcms.nist.gov/fipy/">http://www.ctcms.nist.gov/fipy/</a>>, a python-based finite volume solver.</p>
<p>To start the solver, download and extract the zip archive, open and run 'FVToolStartUp' function.
<br />To see the code in action, copy and paste the following in your Matlab command window:</p>
<p>clc; clear;
<br />L = 50; % domain length
<br />Nx = 20; % number of cells
<br />m = createMesh3D(Nx,Nx,Nx, L,L,L);
<br />BC = createBC(m); % all Neumann boundary condition structure
<br />BC.left.a(:) = 0; BC.left.b(:)=1; BC.left.c(:)=1; % Dirichlet for the left boundary
<br />BC.right.a(:) = 0; BC.right.b(:)=1; BC.right.c(:)=0; % Dirichlet for the right boundary
<br />D_val = 1; % value of the diffusion coefficient
<br />D = createCellVariable(m, D_val); % assign the diffusion coefficient to the cells
<br />D_face = harmonicMean(m, D); % calculate harmonic average of the diffusion coef on the cell faces
<br />Mdiff = diffusionTerm(m, D_face); % matrix of coefficients for the diffusion term
<br />[Mbc, RHSbc] = boundaryCondition(m, BC); % matix of coefficients and RHS vector for the BC
<br />M = Mdiff + Mbc; % matrix of cefficients for the PDE
<br />c = solvePDE(m,M, RHSbc); % send M and RHS to the solver
<br />visualizeCells(m, c); % visualize the results</p>
<p>You can find some animated results of this code in my youtube channel:
<br /><a href="https://www.youtube.com/user/processsimulation/videos">https://www.youtube.com/user/processsimulation/videos</a></p>Ehsanhttp://www.mathworks.com/matlabcentral/fileexchange/authors/383541MATLAB 8.3 (R2014a)MATLAB35710falsetag:www.mathworks.com,2005:FileInfo/488332014-12-21T11:27:00Z2014-12-22T07:00:35ZAABBTREE - A d-dimensional bounding-box tree.A d-dimensional bounding-box tree for collections of objects.<p>AABBTREE offers d-dimensional aabb-tree construction and search for collections of spatial objects. These trees are useful when seeking to implement efficient spatial queries -- determining intersections between collections of objects.
<br />Given a collection of objects, an aabb-tree partitions the bounding-boxes associated with the elements in the collection into a (binary) "tree" -- a hierarchy of rectangular "nodes" that each store a subset of the collection. In contrast to other geometric tree types (quadtrees, kd-trees, etc), aabb-trees are applicable to collections of general objects, rather than just points.</p>
<p>AABBTREE is expected to support additional search queries in the future.</p>
<p>See AABBDEMO, MAKETREE for additional details.</p>Darren Engwirdahttp://www.mathworks.com/matlabcentral/fileexchange/authors/22624MATLAB 7 (R14)falsetag:www.mathworks.com,2005:FileInfo/488122014-12-19T19:08:18Z2014-12-22T07:00:33ZFINDTRIA - Spatial queries for simplexes.Efficient spatial queries for collections of d-simplexes.<p>FINDTRIA computes spatial queries for collections of simplexes (triangles, tetrahedrons, etc) in d-dimensional space. Unlike MATLAB's existing point-location facilities, FINDTRIA supports general collections of simplexes, including non-Delaunay, non-convex, and even overlapping configurations, and can compute multiple intersections per query point.
<br />FINDTRIA is based on an efficient d-dimensional AABB-tree, which is used to speed-up the computation of spatial queries. </p>
<p>FINDTRIA is relatively efficient. It's typically many orders of magnitude faster than brute-force searches, and is often faster than MATLAB's inbuilt routine TSEARCHN, especially when the number of query points is large. MATLAB's inbuilt POINTLOCATION routine is usually faster than FINDTRIA when the underlying triangulation is Delaunay, but is (as of R2014b) typically slower -- sometimes by a large factor -- for non-Delaunay triangulations. It is also restricted to two- and three-dimensional problems.</p>
<p>FINDTRIA was not specifically designed to outperform MATLAB's existing point-location routines (though it sometimes does a good job), it's main purpose is to facilitate efficient queries on non-Delaunay triangulations in arbitrary dimensions -- capabilities that are currently unsupported by existing inbuilt routines.</p>
<p>FINDTRIA is also expected to support additional spatial query types in the future, including line-tria intersections, amongst others.</p>
<p>See FINDTRIADEMO, FINDTRIA for additional details.</p>Darren Engwirdahttp://www.mathworks.com/matlabcentral/fileexchange/authors/22624MATLAB 7 (R14)48833falsetag:www.mathworks.com,2005:FileInfo/486092014-12-01T10:01:31Z2014-12-22T07:00:29ZDUALMESH - Polygonal mesh construction.Construct polygonal "dual" meshes from 2-simplex triangulations embedded in R^3.<p>DUALMESH is a toolbox of mesh processing routines that allow the construction of "dual" meshes based on underlying simplicial triangulations. Support is provided for various planar and surface triangulation types, including non-Delaunay and non-manifold types.
<br />DUALMESH makes use of a "generalised" dual-mesh paradigm that guarantees dual cells are "star-shaped" w.r.t. their associated generating vertices, even when mesh quality is very low or for highly curved surface discretisations. This generalised dual-mesh is equivalent to the conventional Voronoi diagram when the input is a so-called "well-centred" Delaunay triangulation.
<br />Dual-meshes are useful for a variety of numerical methods, and are often used as a basis for unstructured finite-volume or discontinuous Galerkin finite-element formulations.
<br />See DEMODUAL2, MAKEDUAL2 for additional information.</p>Darren Engwirdahttp://www.mathworks.com/matlabcentral/fileexchange/authors/22624MATLAB 7 (R14)falsetag:www.mathworks.com,2005:FileInfo/487742014-12-17T13:48:50Z2014-12-17T14:00:01ZLoad Leica LIF FileLoad Leica LIF File<p>ci_loadLif - Load Leica Image File Format
<br />Based on HKLoadlif by Hiroshi Kawaguchi
<br /><a href="http://de.mathworks.com/matlabcentral/fileexchange/36005-leica-image-format-file-loader">http://de.mathworks.com/matlabcentral/fileexchange/36005-leica-image-format-file-loader</a>
<br />[imgout]=ci_loadLif('filename', getonlynumberofelements, number) loads an image (series) from a Leica Image File
<br />imgout =
<br /> Image: {[1024x1024x101 uint8]}
<br /> Info: [1x1 struct]
<br /> Name: 'loc1'
<br /> Type: 'X-Y-Z'
<br /> NumberOfChannel: 1
<br /> Size: '1024 1024 101'</p>
<p>Some LAS-AF 4.x files give errors, fixed in LAS-X</p>Ron Hoebehttp://www.mathworks.com/matlabcentral/fileexchange/authors/536509MATLAB 8.1 (R2013a)MATLABfalsetag:www.mathworks.com,2005:FileInfo/487652014-12-16T16:44:51Z2014-12-16T16:45:45ZpointsToSurf(x,y,z)Creates a surface using data inputs of the 3 axes<p>How do you turn a collection of XYZ triplets into a surface plot?
<br />This function uses inherent matlab functions like griddata and surf to make a 3D surface using only the X,Y,Z vectors.</p>Ankit Chiplunkarhttp://www.mathworks.com/matlabcentral/fileexchange/authors/536231MATLAB 6.5 (R13)falsetag:www.mathworks.com,2005:FileInfo/440472013-10-22T23:22:24Z2014-12-09T14:53:36ZPlot a circle in 3DThe function plots a circle with user defined radius, position and direction<p>This function needs three input parameters:
<br />*Circle radius
<br />*position of the circle midpoint
<br />*vector perpendicular to the surface in which the circle is plotted.
<br />With help of scatter3, the circle is plotted into the current axes and the handle for the new plot is returned to the user</p>Andreas Schmidhttp://www.mathworks.com/matlabcentral/fileexchange/authors/278438MATLAB 8.2 (R2013b)MATLABMultiple inputs for additional circles follows in the near future, as soon as I find some time :-)falsetag:www.mathworks.com,2005:FileInfo/486562014-12-04T19:54:10Z2014-12-08T20:59:40ZclickzEasily get z values of pcolor or image plots from mouse clicks.<p>Sometimes I plot a pcolor or image plot and I want to know with some precision what values exist a specific locations. The Data Cursor tool in the figure window does not return z values for pcolor plots, so I end up with my eyes darting back and forth between the location of interest in the pcolor plot and the colorbar, trying to pin down the z value at the interesting location.
<br />This function temporarily prints z values corresponding to clicked points on a surface or image. If multiple surfaces or images exist in the same axes, clickz first looks for surfaces and determines the one on the top of the graphical stack is the relevant one. If no surfaces exist, but an image or multiple images exist, clickz probes the image on the top of the graphical stack.</p>
<p>To find "z" values of an existing image or pcolor plot, simply type clickz and start clicking on areas of interest. Instead of clicking, you may also hit any key on the keyboard except the keys listed below which perform the following functions:</p>
<p> Carriage return terminates data entry.
<br /> + or z zooms in, centered on current cursor location.
<br /> - or x zooms out, centered on current cursor location.</p>
<p>Occasionally, linear interpolation between plotted data points fails, such as when xdata and ydata are not perfectly monotonic and plaid. I've only run into this problem when plotting polar stereographic data referenced one latitude, onto a polar stereographic map referenced to another latitude. If for some reason linear interpolation fails, clickz will attempt to find the nearest x,y data points by Euclidean distance, and will print z data at that nearby location. In such a case, any output x,y,z data will reflect the nearby point instead of the clicked point.</p>
<p>Syntax
<br />clickz
<br />clickz(N)
<br />clickz(...,ax)
<br />clickz(...,'keep')
<br />clickz(,...'TextProperty',TextValue)
<br />z = clickz(...)
<br />[x,y,z] = clickz(...)
<br />[x,y,z,h] = clickz(...)</p>
<p>Description
<br />clickz temporarily prints a z value on a plot at each click location. Previous printed values are deleted with each new click. clickz continues to run until user hits Return on the keyboard.</p>
<p>clickz(N) performs clickz N times or until the user hits Return on the keyboard. If N is specified with 'keep' and/or text formatting, N must be the first input argument.</p>
<p>clickz(...,ax) specifies an axis handle ax on which to use clickz.</p>
<p>clickz(...,'keep') does not delete printed points.</p>
<p>clickz(,...'TextProperty',TextValue) formats printed text. Multiple text properties and values may be specified, including fontsize, color, background, etc.</p>
<p>z = clickz(...) returns an array of clicked z values.</p>
<p>[x,y,z] = clickz(...) returns clicked x, y, and z values.</p>
<p>[x,y,z,h] = clickz(...) also returns text object handle h when the 'keep' command is used and all four outputs are requested by the user.</p>Chad Greenehttp://www.mathworks.com/matlabcentral/fileexchange/authors/225623MATLAB 8.4 (R2014b)MATLAB206453870348517false