tag:www.mathworks.com,2005:/matlabcentral/fileexchange/feedMATLAB Central File Exchangeicon.pnglogo.pngMATLAB Central - File ExchangeUser-contributed code library2015-01-26T01:58:02-05:00228821100tag:www.mathworks.com,2005:FileInfo/491632015-01-26T06:17:29Z2015-01-26T06:17:29ZNumerical Solution of 1D Time Independent Schrodinger Equation using Finite Difference Method.Finite Difference scheme is applied to Time Independent Schrodinger Equation.<p>In this code, a potential well is taken (particle in a box) and the wave-function of the particle is calculated by solving Schrodinger equation. Finite difference method is used. Energy must be prescribed before calculating wave-function. Also constants like mass, Planck's constant and length of potential well are all normalized to unity for simplicity. At the end, wave-function is normalized to get probability density function using MATLAB inbuilt trapz command (trapezoidal rule) for numerical integration. Finally for visualizing, some array manipulation is done. For four different energy level, wave-function (or the probability density function) is plotted at the end.</p>Sathyanarayan Raohttp://www.mathworks.com/matlabcentral/profile/authors/2686490-sathyanarayan-raoMATLAB 7.14 (R2012a)falsetag:www.mathworks.com,2005:FileInfo/491622015-01-26T05:57:26Z2015-01-26T05:57:26ZfastFindKFind k occurances of a value in array. Slightly faster than the usual routs.<p>Example :
<br />>> a = [ 1 4 5 4 4 7 4 4 9 4 ];
<br />>> find(a==4,5)</p>
<p>ans =</p>
<p> 2 4 5 7 8</p>
<p>>> fastFindK(4,a,5)</p>
<p>ans =</p>
<p> 2
<br /> 4
<br /> 5
<br /> 7
<br /> 8</p>
<p>I had a situation in which I was looking for indices many many times. Unfortunately, I could not get around the problem via logical arrays or anything of that sort (there was quite a bit of code which I would have to change otherwise). So I did what any rational programmer would do, that is I wasted a good few precious minuets and one or two unnecessary keystrokes to write this lame code. </p>
<p>I recommend just using logical arrays .....</p>Christopher Harrishttp://www.mathworks.com/matlabcentral/profile/authors/4077745-christopher-harrisMATLAB 8.1 (R2013a)falsetag:www.mathworks.com,2005:FileInfo/491522015-01-25T08:18:50Z2015-01-26T03:30:19ZMaximin Separation Probability ClusteringMaximin Separation Probability Clustering (Huang, et al. AAAI 2015)<p>Fast binary clustering algorithm.
<br />Code for Maximin Separation Probability Clustering (Huang, et al. AAAI 2015);</p>Gao Huanghttp://www.mathworks.com/matlabcentral/profile/authors/6100300-gao-huangMATLAB 8.1 (R2013a)Statistics ToolboxMATLABfalsetag:www.mathworks.com,2005:FileInfo/491612015-01-26T03:27:56Z2015-01-26T03:27:56Zfzero_allExtends functionality of fzero by dividing interval into sub-intervals and applying fzero on them.<p>Attempts to find zeros of f in a given by sampling f at N points inside the interval. The function then looks for intervals where f changes sign and applies fzero on them. If max_sols is specified, this function always returns vectors of length |max_sols| so the calling function may easily store the result in a matrix. WARNING: This function will not find roots of even multiplicity (x-x0)^2 and may miss other roots if they are spaced closer than the sampling interval.</p>Thomas Galvinhttp://www.mathworks.com/matlabcentral/profile/authors/897219-thomas-galvinMATLAB 8.2 (R2013b)falsetag:www.mathworks.com,2005:FileInfo/491602015-01-25T23:44:30Z2015-01-26T00:01:35ZFast mesh-mesh intersection using ray-tri intersection with octree spatial partitioning.Fast mesh-mesh intersection based on ray-tri solution. Octree partitioning gives large speed-up.<p>% Putative points of intersection between each pair of surfaces are located
<br />% by assuming that each constituent mesh triangle edge represents an
<br />% infinitesimal ray, then solving the ray-triangle intersection problem
<br />% using the Barycentric coordinate based solution presented by Möller and
<br />% Trumbore [1997: vectorized implementation for speed]. Positive
<br />% intersections occur when the intersecting point, p0 lies between the end
<br />% nodes of its corresponding triangle edge (p1, p2), identified when the
<br />% following criterion is satisfied:
<br />% ‖p0 - p1‖ + ‖p0 - p2‖ = ‖p1 - p2‖
<br />% Note: rounding errors do not permit solving of the above criteria
<br />% directly. Dot and cross functions are instead used for constraining
<br />% whether the point is between the triangle edge end nodes.
<br />% Ray tracing becomes prohibitive for meshes greater than a few thousand
<br />% triangles. The reliance on spatial partitioning using octree subdivision
<br />% carries overhead in binning the two input meshes, but is still usually
<br />% MUCH faster than a brute force search for most mesh objects.
<br />% INPUT:
<br />% pointsA: nx3 vertex list for mesh A
<br />% pointsB: nx3 vertex list for mesh B
<br />% facesA: nx3 face list of triangle corner indices for mesh A
<br />% facesB: nx3 face list of triangle corner indices for mesh B
<br />% octs: maximum bin size (single integer)</p>
<p>% OUTPUT
<br />% intersections: nx3 vertex list of intersections between the two meshes</p>
<p>% Note: the octree object is created using the excellent octree.m function of Sven:
<br />% <a href="http://www.mathworks.com/matlabcentral/fileexchange/40732-octree-partitioning-3d-points-into-spatial-">http://www.mathworks.com/matlabcentral/fileexchange/40732-octree-partitioning-3d-points-into-spatial-</a>
<br />% subvolumes</p>
<p>% Test data (testData.mat) containing two meshed intersecting fractal surfaces is provided with the package</p>Thomashttp://www.mathworks.com/matlabcentral/profile/authors/3752776-thomasMATLAB 8.1 (R2013a)MATLAB8005falsetag:www.mathworks.com,2005:FileInfo/491592015-01-25T22:12:01Z2015-01-25T22:12:01Z4to4 MIMO 16QAM OFDM turbo code Rayleigh channel- BERbuy this at dr_freelancer at yaho<p>4to4 MIMO 16QAM OFDM turbo code Rayleigh channel- BER</p>Dr Freelancerhttp://www.mathworks.com/matlabcentral/profile/authors/6090458-dr-freelancerMATLAB 7.14 (R2012a)falsetag:www.mathworks.com,2005:FileInfo/491582015-01-25T20:54:21Z2015-01-25T20:54:21ZcatStructs.ccatStructs.c concatinates two structures, each with unique feilds. Outputs one structure.<p>I found myself in the situation of needing to concatenate two structures together and it seems that Matlab does not have a very clean method of accomplishing this. In fact, I think the next best thing to do is something like:
<br />>> a(1).a = [1 2 3];a(2).a = [2 3 4]; a(1).b = 'hello';a(2).b = 'again';
<br />>> b(1).c = {1 2 3 4};b(2).c = {3 4 5 6};
<br />>> x = b;
<br />>> names = fieldnames(a);
<br />>> for i=1:numel(names);for j=1:numel(a);x(j).(names{i}) = a(j).(names{i});end;end
<br />>> x</p>
<p>x = </p>
<p>1x2 struct array with fields:</p>
<p> c
<br /> a
<br /> b
<br />>> x(1)</p>
<p>ans = </p>
<p> c: {[1] [2] [3] [4]}
<br /> a: [1 2 3]
<br /> b: 'hello'</p>
<p>Which I hate to do (not to mention it looks dumb and clunky). </p>
<p>After a while, I decided to just make another silly function to accomplish this silly task. It takes two structures (should have the same number of dimensions!!) and outputs the concatenation of the two. The two inputs should have unique field names (as in the example above) and each field across each dimension should be similar (ie. a(1).a and a(2).a are both numerical arrays).</p>
<p>Example :</p>
<p>>> xx = catStructs(a,b)
<br />xx =
<br />1x2 struct array with fields:</p>
<p> a
<br /> b
<br /> c</p>
<p>>> a(1).a = [1 2 3];a(2).a = [2 3 4]; a(1).b = 'hello';a(2).b = 'again';
<br />>> b(1).c = {1 2 3 4};b(2).c = {3 4 5 6};
<br />>> xx(1)
<br />ans =
<br /> a: [1 2 3]
<br /> b: 'hello'
<br /> c: {[1] [2] [3] [4]}</p>
<p>Unfortunately, it is a bit slower that the forloop method when the array sizes become very large. I have not optimized the code yet. I created it merely for code tidiness.</p>Christopher Harrishttp://www.mathworks.com/matlabcentral/profile/authors/4077745-christopher-harrisMATLAB 8.1 (R2013a)falsetag:www.mathworks.com,2005:FileInfo/476402014-08-24T00:35:37Z2015-01-25T20:21:17ZASAID grounding linesGet and plot grounding line and hydrostatic line data from ASAID. <p>This Antarctic Mapping Tools plugin plots grounding line data from the Antarctic Surface Accumulation and Ice Discharge (ASAID) project.</p>Chad Greenehttp://www.mathworks.com/matlabcentral/profile/authors/1062128-chad-greeneMATLAB 8.0 (R2012b)Mapping ToolboxMATLABRequires Antarctic Mapping Tools: www.mathworks.com/matlabcentral/fileexchange/4763847638falsetag:www.mathworks.com,2005:FileInfo/476382014-08-23T23:39:06Z2015-01-25T20:11:12ZAntarctic Mapping ToolsA toolbox for analysis and display of Antarctica-related data<p>This toolbox has been designed to streamline the process of importing, analyzing, and displaying Antarctica-related data. The functions in this toolbox have been designed to provide a standard framework to allow easy pairing of multiple different types of data sets (surface elevation, ice velocity, grounding line, etc).
<br />This toolbox is required for:
<br />* The Bedmap2 Toolbox for Matlab
<br />* The Measures velocity mapping and interpolation toolbox
<br />* Icesat grounding zone structure function
<br />* ASAID grounding zone structure function
<br />* Antarctic Basins function.
<br />* MODIS MOA image plotting</p>Chad Greenehttp://www.mathworks.com/matlabcentral/profile/authors/1062128-chad-greeneMATLAB 8.0 (R2012b)Mapping ToolboxStatistics ToolboxSimulink 3D AnimationMATLABMatlab's Mapping Toolbox is required for some of the tools in this toolbox.9615falsetag:www.mathworks.com,2005:FileInfo/491572015-01-25T19:38:07Z2015-01-25T19:39:28Zinpolygon_for_gpuinpolygon function that works using gpuArray<p>Code which runs many point-in-polygon tests in parallel on the gpu. The inputs are a single polygon and many test points. Inputs must all be gpuArray objects in order to see any speed increase.
<br />Disclaimer: Runnning this code on less than ~1e5 test points will usually result in slowdown rather than speedup. The number of vertices should be much less than the number of test points, and the number of test points should be large enough to properly utilize the GPU. All inputs should be of type gpuArray (this is important to see any speed increase! Without gpuArrays this function is much slower than Matlab's inpolygon function). </p>
<p>I am hoping that re-implementing this using mex CUDA code will result in faster run-times. For best results, the number of test points should be close to the maximum array size on your GPU. </p>
<p>This implementation of the ray-casting algorithm is based on C code by W. Randolf Franklin, which can be found at <a href="http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html">http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html</a></p>
<p>Any advice is welcome on how to speed up this algorithm, or make it more useful. Thanks!</p>
<p>Example:</p>
<p>L = linspace(0,2.*pi,6);
<br />xv = gpuArray(cos(L)');
<br />yv = gpuArray(sin(L)');</p>
<p>pts_x=gpuArray(rand(1e5,1));
<br />pts_y=gpuArray(rand(1e5,1));</p>
<p>tic
<br />in=inpolygon_for_gpu(pts_x, pts_y, xv, ,yv);
<br />toc</p>Sulimon Sattarihttp://www.mathworks.com/matlabcentral/profile/authors/4255258-sulimon-sattariMATLAB 8.0 (R2012b)Parallel Computing ToolboxGPU device that supports NVIDIA CUDA codefalse