tag:www.mathworks.com,2005:/matlabcentral/fileexchange/feedMATLAB Central File Exchangeicon.pnglogo.pngMATLAB Central - File Exchange - type:Example category:"Graphics"User-contributed code library2015-01-30T09:55:35-05:00531100tag:www.mathworks.com,2005:FileInfo/491192015-01-22T18:53:16Z2015-01-22T18:53:16ZpolyplotEasily plot linear trend lines or polynomial fits to scattered data.<p>This function simply plots a polynomial fit to scattered x,y data. This function can be used to easily add a linear trend line or other polynomial fit to a data plot.</p>
<p>Syntax
<br />polyplot(x,y)
<br />polyplot(x,y,n)
<br />polyplot(...,'LineProperty',LineValue,...)
<br />polyplot(...,'error')
<br />polyplot(...,'error','ErrorLineProperty',ErrorLineValue)
<br />[h,p,delta] = polyplot(...)</p>
<p>Description
<br />polyplot(x,y) places a least-squares linear trend line through scattered x,y data.</p>
<p>polyplot(x,y,n) specifies the degree n of the polynomial fit to the x,y data. Default n is 1.</p>
<p>polyplot(...,'LineProperty',LineValue,...) formats linestyle using LineSpec property name-value pairs (e.g., 'linewidth',3).</p>
<p>polyplot(...,'error') includes lines corresponding to approximately +/- 1 standard deviation of errors delta. At least 50% of data should lie within the bounds of error lines.</p>
<p>polyplot(...,'error','ErrorLineProperty',ErrorLineValue) formats error lines with line property name-value pairs. All arguments occurring after 'error' are assumed to be error line property specifications.</p>
<p>[h,p,delta] = polyplot(...) returns handle(s) h of plotted line(s), coefficients p of polynomial fit p(x), and error estimate delta, which is the standard deviation of error in predicting a future observation at x by p(x). Assuming independent, normal, constant-variance errors, y +/- delta contains at least 50% of the predictions of future observations at x.</p>Chad Greenehttp://www.mathworks.com/matlabcentral/profile/authors/1062128-chad-greeneMATLAB 8.0 (R2012b)2315146363falsetag:www.mathworks.com,2005:FileInfo/485762014-12-05T17:27:04Z2015-01-14T20:16:39ZcircularGraphPlot an interactive circular graph to illustrate connections in a network.<p>A 'circular graph' is a visualization of a network of nodes and their connections. The nodes are laid out along a circle, and the connections are drawn within the circle. Click on a node to make the connections that emanate from it more visible or less visible. Click on the 'Show All' button to make all nodes and their connections visible. Click on the 'Hide All' button to make all nodes and their connections less visible.</p>Paul Kassebaumhttp://www.mathworks.com/matlabcentral/profile/authors/3559574-paul-kassebaumMATLAB 8.4 (R2014b)MATLABfalsetag: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/profile/authors/2336153-ehsanMATLAB 8.3 (R2014a)MATLAB35710falsetag:www.mathworks.com,2005:FileInfo/487092014-12-10T18:44:17Z2014-12-11T15:33:44ZcustomGridAdds a customisable grid to a 2D plot<p>Enables the custom setting of the position of an axes grid lines on a 2D plot. Grid lines can be arbitrary placed on figure axes with customisable colour, width, line styles and alpha. The user can also supply a set of X and Y points to define their own grid lines, e.g. at 45 degrees or curved grids.
<br />To enable alpha blending of the lines in order to mimic Matlab's grid function the lines are drawn as the edges of patches using Brett Shoelson's patchline function. This was released for Matlab 2012 and providing this works, there is no reason this function should not work in earlier versions of Matlab.</p>Philhttp://www.mathworks.com/matlabcentral/profile/authors/1921854-philMATLAB 8.3 (R2014a)MATLAB36953falsetag: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/profile/authors/1062128-chad-greeneMATLAB 8.4 (R2014b)MATLAB206453870348517falsetag:www.mathworks.com,2005:FileInfo/389772012-11-09T01:38:59Z2014-12-03T02:36:05ZDimensioned variable class - units support for MATLABA new variable type allowing use of real-world units and dimensions with enforced unit consistency.<p>A DimVar (Dimensioned Variable) object attaches real-world units (any combination of mass, length, time, etc.) to otherwise normal numeric variables. Math operations performed on dimensioned variables will automatically perform dimensional analysis to ensure that units are consistent.
<br />In my experience this tool has helped me reduce units-related errors, has made my code much easier to understand, and has also generally sped up my work. It is also very handy for day-to-day unit conversions and other small tasks.</p>
<p>Recent feature additions:
<br />-Easily switch to using a different base unit system and work in any base unit system you like, e.g. English units (default is still SI).
<br />-Added fuller functionality to several methods.
<br />-Sped up and/or simplified several methods, some significantly.
<br />-More methods, including plot, disp, num2str, and others.</p>
<p>Rob is responsible for the first iterations of this submission: <a href="http://www.mathworks.com/matlabcentral/fileexchange/10070">http://www.mathworks.com/matlabcentral/fileexchange/10070</a></p>Sky Sartoriushttp://www.mathworks.com/matlabcentral/profile/authors/5429562-sky-sartoriusMATLAB 8.1 (R2013a)MATLABfalsetag:www.mathworks.com,2005:FileInfo/486132014-12-01T17:04:46Z2014-12-01T17:04:46ZSurface IntersectionIntersection of two triangulated surfaces<p>Function calculates intersection of any two triangulated surfaces using triangle/triangle intersection algorithm proposed by Tomas Möller (1997) and implemented as highly vectorized MATLAB code. The algorithm was expanded to include calculation of the intersection surface, in addition to boolean matrix cataloging which triangle from one surface intersects with which triangle in the other surface. Function can be used for contour line calculations and can handle surfaces residing on the same plane.</p>Jaroslaw Tuszynskihttp://www.mathworks.com/matlabcentral/profile/authors/35549-jaroslaw-tuszynskiMATLAB 8.4 (R2014b)falsetag:www.mathworks.com,2005:FileInfo/484262014-11-11T22:49:46Z2014-11-11T22:49:46Zparulyparula-like color map<p>In the process of updating all my old scripts to work with Matlab R2014b, I've found that sometimes I want to generate the new default colormap while using R2012b. This function returns a blueish-greenish-orangey-yellowish color map which mimics, but does not exactly match the default parula color map introduced in Matlab R2014b. </p>
<p>Syntax and Description:
<br />map = paruly(n) returns an n-by-3 matrix containing a parula-like colormap. If n is not specified, a value of 64 is used.</p>Chad Greenehttp://www.mathworks.com/matlabcentral/profile/authors/1062128-chad-greeneMATLAB 8.0 (R2012b)MATLAB289823408742673437004520846874falsetag:www.mathworks.com,2005:FileInfo/466432014-05-30T20:23:52Z2014-10-27T20:08:44ZSpriteKit FrameworkFramework for designing animated and interactive Sprites and gameplay<p>SpriteKit is intended to be a framework for MATLAB game developers by abstracting out as much of the graphics interactions as possible, resulting in a clean interface for fast development and code with high readability.
<br />See demos/examples for animated GIFs of sample gameplay.</p>Steve McClurehttp://www.mathworks.com/matlabcentral/profile/authors/3521545-steve-mcclureMATLAB 8.3 (R2014a)Communications System ToolboxCommunications System ToolboxImage Processing ToolboxMATLABMATLAB4096145795falsetag:www.mathworks.com,2005:FileInfo/78442005-06-13T11:39:30Z2014-10-27T13:36:56Zgeom2dGeometry library for matlab. Performs geometric computations on points, lines, circles, polygons...<p>Geometry library to handle and visualize geometric primitives such as points, lines, circles and ellipses, polylines and polygons...
<br />The goal is to provide a low-level library for manipulating geometrical primitives, making easier the development of more complex geometric algorithms.
<br />The library proposes functions to:</p>
<p>- create various shapes (points, circles, lines, ellipses, polylines, polygons) using an intuitive syntax. Ex: createCircle(p1, p2, p3) to create a circle through 3 points.</p>
<p>- derive new shapes: intersection between 2 lines, between a line and a circle, parallel and perpendicular lines
<br />Functions to compute intersections</p>
<p>- work on polylines and polygons: compute centroid and area, expand, clip with half-plane...</p>
<p>- measure distances (between points, a point and a line, a point and a group of points), angle (of a line, between 3 points), or test geometry (point on a line, on a circle).</p>
<p>- manipulate planar transformation. Ex: P2 = transformPoint(P1, createRotation(CENTER, THETA));</p>
<p>- draw shapes easily. Ex: drawCircle([50 50], 25), drawLine([X0 Y0 DX DY]). Some clipping is performed for infinite shapes such as lines or rays.</p>
<p>Additional help is provided in geom/Contents.m file, as well as summary files like 'points2d.m' or 'lines2d.m'.</p>
<p>Note: the project has merged with the geom3d library (FeX 24484), and is now hosted on sourceforge: <a href="http://matgeom.sourceforge.net/">http://matgeom.sourceforge.net/</a>
</p>David Leglandhttp://www.mathworks.com/matlabcentral/profile/authors/127343-david-leglandMATLAB 8.3 (R2014a)Image Processing ToolboxImage Processing ToolboxImage Processing ToolboxSignal Processing ToolboxSignal Processing ToolboxSignal Processing ToolboxMATLABMATLABMATLABSome functions (for shape fitting) require the optimization toolbox.false