RUNLENGTH - Run-length codingRun-length encoding splits a vector into one vector, which contains theelements without neighboring repetitions, and a second vector, whichcontains the number of repetitions.This can reduce the memory for storing the data or allow to analyze sequences.Encoding: [B, N, BI] = RunLength(X)Decoding: X = RunLength(B, N)INPUT / OUTPUT: X: Full input signal, row or column vector. Types: (U)INT8/16/32/64, SINGLE, DOUBLE, LOGICAL, CHAR. B: Compressed data, neighboring elements with the same value are removed. B and X have the same types. N: Number of repetitions of the elements of B in X as DOUBLE or UINT8 row vector. BI: Indices of elements in B in X as DOUBLE row vector.RunLength(X, 'byte') replies N as UINT8 vector.You can find a lot of RLE tools in the FileExchange already. This C-Mex isabout 5 times faster than good vectorized M-versions.The M-file RunLength_M contains vectorized and loop M-code for education.EXAMPLES:Encode and decode: [b, n] = RunLength([8, 9, 9, 10, 10, 10, 11]) x = RunLength(b, n) % b = [8,9,10,11], n = [1,2,3,1], x = [8,9,9,10,10,10,11]Limit counter to 255: [b, n] = RunLength(ones(1, 257), 'byte') % b = [1, 1], n = uint8([255, 2])LOGICAL input: [b, n] = RunLength([true(257, 1); false]) % b = [true; false], n = [257, 1]Find the longest sequence: x = floor(rand(1, 1e6) * 2); [b, n, bi] = RunLength(x); [longestRun, index] = max(n); longestPos = bi(index);The C-code is compiled automatically the first time RunLength is called.See "RunLength_ReadMe.txt" for more details.The unit-test uTest_RunLength tests validity and speed.Tested: Matlab 6.5, 7.7, 7.8, 7.13, WinXP/32, Win7/64 Compiler: LCC3.8, BCC5.5, OWC1.8, MSVC2008/2010Does not compile under LCC2.4 shipped with Matlab/32!Assumed Compatibility: higher Matlab versions, Linux, MacOS.

In MATLAB® 7.7 the default layout was changed. Choosing "Default" from the Desktop Layout menu now arranges desktop tools in three columns where previously they appeared in two columns. If you prefer the old, two column, layout follow the steps below to add a "Classic Default" item to the Desktop Layout menu.1. At the MATLAB prompt issue the prefdir command2. Copy the attached file into the reported directory3. Restart MATLAB4. Choose Desktop -> Desktop Layout -> Classic Default from the menu bar

VChooseK(V, K) creates a matrix, which rows are all combinations of choosing K elements of the vector V without order and without repititions.INPUT: V: Array of class DOUBLE, SINGLE, (U)INT8/16/32/64, LOGICAL, CHAR. K: Number of elements to choose.OUTPUT: Y: Matrix of size [N!/K!(N-K)!, K] with N is the number of elements of V. Y has the same class as the input V. The output equals Matlab's NCHOOSEK, except that NCHOOSEK replies the number of combinations for a scalar V: VChooseK(-1, 1) replies [-1]: One element taken out of a set of length one. NCHOOSEK(-1, 1) fails at calculating N!/K!(N-K)!.EXAMPLES: Choose 2 elements from [1,2,3,4]: VChooseK(1:4, 2) ==> [1,2; 1,3; 1,4; 2,3; 2,4; 3,4] For speed cast the input to integer types if possible: Y = double(VChooseK(int16(1:1000), 2); is faster than: Y = VChooseK(1:1000, 2); To get the combinations of cell arrays, use the combinations of the index: C = {'a', 'b', 'c', 'd'}; C2 = C(VChooseK(1:4, 2)) ==> C2 = {'a', 'b'; 'a', 'c'; 'a', 'd'; 'b', 'c'; 'b', 'd'; 'c', 'd'}INSPIRATION:Jos van der Geest has published an efficient NCHOOSE2, which is much faster than Matlab's NCHOOSEK: http://www.mathworks.com/matlabcentral/fileexchange/20144I was curious, if a MEX version is much faster. At first I've created NChoose2q, which was 5 times faster than Jos' Matlab implementation. But the algorithm was so simple in C and did not consume temporary memory, that I've expanded it to K=3,4,5 soon. The algorithm for free K was more challenging, but it needs just 3*K pointers for temporary memory. Therefore it is much faster than Matlab's NCHOOSEK (Matlab 7.8, 1.5GHz Pentium-M, 512 MB): NCHOOSEK(1:50, 5): 45.30 sec VChooseK(1:50, 5): 0.32 sec => 141 times faster NCHOOSEK(1:20, 16): 0.52 sec VChooseK(1:20, 16) 0.0024 sec => 216 times faster NCHOOSEK(int8(1:40), 4): 0.64 sec VChooseK(int8(1:40), 4): 0.001562 sec => 410 times fasterThe powerful COMBINATOR of Matt Fig handles repititions and ordered sequences also, but for its specific job VChooseK is remarkably faster (see screen shot).Tested: Matlab 6.5, 7.7, 7.8, WinXPCompilers: BCC5.5, LCC2.4/3.8, Open Watcom 1.8Please run the unit-test TestVChooseK after compiling and for speed comparisons.

MinGW-w64 is a compiler suite for Windows based on the GNU tool chain. It includes a GCC compiler and related tools for compiling C/C++/Fortran applications for Windows. C/C++/Fortran applications compiled with MinGW-w64 GCC can be called from MATLAB using MEX (see table for release limitations on Fortran support). This GCC compiler can also be helpful for other MathWorks products that require a C/C++/Fortran compiler. Installation Instructions:Select the button in the upper right-hand corner of this page. It might be labelled "Install" or "Download". "Install" button instructions: Select either the "Install" or "Download Only" option.If the "Install" option is selected, follow the guided steps to install MinGW. If the "Download Only" option is selected, save the file to the desired folder then double-click on the file or drag it into the MATLAB Command Window to install."Download" button instructions: Save the file to the desired folder then double-click on the file or drag it into the MATLAB Command Window to install.Version-specific InstructionsR2023b and later: MinGW 8.1 is supported for automatic installation by selecting the button in the upper right-hand corner of this page. It might be labelled "Install" or "Download". MinGW 6.3 must be configured manually. Download MinGW 6.3 from here, then double-click on the file or drag it into the MATLAB Command Window to install. R2023a: MinGW 8.1 must be configured manually. Download MinGW 8.1 from here, then double-click on the file or drag it into the MATLAB Command Window to install. MinGW 6.3 is supported for automatic installation by selecting the button in the upper right-hand corner of this page. It might be labelled "Install" or "Download". MinGW 6.3 must be configured manually. To Configure MinGW as a MEX compiler: Follow instructions on this page.FAQ: This link provides answers to some frequently asked questions.See additional information on installing this compiler at: http://www.mathworks.com/help/matlab/matlab_external/install-mingw-support-package.html Learn more about other compilers supported by MathWorks Products at: https://www.mathworks.com/support/requirements/supported-compilers.htmlIf you are having difficulty installing, please contact Technical Support or see MATLAB Answers: https://www.mathworks.com/support/contact_us.html https://www.mathworks.com/matlabcentral/answers/?term=mingw

DATAHASH - Hash for Matlab array, struct, cell or fileHash = DataHash(Data, Opts, ...) Data: Array of built-in types (U)INT8/16/32/64, SINGLE, DOUBLE (real or complex) CHAR, LOGICAL, CELL, STRUCT (scalar or array, nested), function_handle. Options: List of char vectors: Hashing method: 'SHA-1', 'SHA-256', 'SHA-384', 'SHA-512', 'MD2', 'MD5'. Output format: 'hex', 'HEX', 'double', 'uint8', 'base64' Input type: 'array': The contents, type and size of the input [Data] are considered for the creation of the hash. Nested CELLs and STRUCT arrays are parsed recursively. Empty arrays of different type reply different hashs. 'file': [Data] is treated as file name and the hash is calculated for the files contents. 'bin': [Data] is a numerical, LOGICAL or CHAR array. Only the binary contents of the array is considered, such that e.g. empty arrays of different type reply the same hash. 'ascii': Same as 'bin', but only the 8-bit ASCII part of the 16-bit Matlab CHARs is considered. Hash: String or numeric vector.EXAMPLES:Default: MD5, hex: DataHash([]) % 7de5637fd217d0e44e0082f4d79b3e73SHA-1, Base64: S.a = uint8([]); S.b = {{1:10}, struct('q', uint64(415))}; DataHash(S, 'base64', 'SHA-1') % ZMe4eUAp0G9TDrvSW0/Qc0gQ9/AComparison with standard hash programs using ASCII strings: DataHash('abc', 'SHA-256', 'ascii')Michael Kleder's "Compute Hash" works similar, but does not accept structs, cells or files: http://www.mathworks.com/matlabcentral/fileexchange/8944"GetMD5" is 2 to 100 times faster, but it replies only MD5 hashes and a C-compiler is required: http://www.mathworks.com/matlabcentral/fileexchange/25921Tested: Matlab 7.7, 7.8, 7.13, 8.6, 9.1, 9.5, Win7&10/64, Java: 1.3, 1.6, 1.7Bugreports and enhancement requests are welcome. Feel free to ask me about a version for Matlab 6.5.PS. MD5 and SHA1 hash values are "broken": You can construct a data set, which has a specific hash. But to check the integrity of files or to to recognize a set of variables, both methods are reliable.

Find overlap of 2 cell strings.This can be used for a faster calculation of: INTERSECT, ISMEMBER, SETDIFF and UNION.Comparison to Matlab's INTERSECT:- Consider repeated strings (no internal UNIQUE)- No sorting- Can be insensitive for upper/lower case- M-version as demonstration of the method- MEX-version: 90% to 98% faster than INTERSECT[AI, BI] = CStrAinBP(A, B, CaseSensitive)INPUT: A, B: Cell strings. CaseSensitive: Optional string to trigger sensitivity for case.OUTPUT: AI: Indices of common strings in A. Each occurence of repeated strings is considered. AI is sorted from low to high indices. BI: Indices of common strings in B. If B is not unique, the first occurrence of a string is used. such that A{AI} == B{BI}.EXAMPLES: [AI, BI] = CStrAinBP({'a', 'b', 'q', 'a'}, {'a', 'c', 'd', 'a', 'b'}) replies: AI = [1, 2, 4] and: BI = [1, 5, 1] [AI, BI] = CStrAinBP({'a', 'b', 'A'}, {'a', 'c', 'a', 'B', 'b'}, 'i') replies: AI = [1, 2, 3] and: BI = [1, 4, 1]INCLUDED FILES: CStrAinBP.m: Proof of concept, demonstration. CStrAinBP.C: Fast MEX function. CStrAinBP.MEXW32: Compiled for Matlab 7 with LCC3.8. Please recompile it with your favorite compiler. Matlab6/CStrAinBP.DLL: Compiled for Matlab 6 with BCC5.5. For Matlab 6, replace the MEXW32 file by this DLL. TestCStrAinBP: Run the test after installation or compiling.Tested: Matlab 6.5, 7.7, 7.8, Win2K/XP

FilterM, FiltFiltM: Fast digital filterThese functions are compatible to MATLAB's FILTER and FILTFILT commands,but they are faster (see screenshot): FilterM: 30%-40% of FILTER runtime FiltFiltM: 4%-20% of FILTFILT runtimeADDITIONAL FEATURES:- The dimension to operate on can be specified for FiltFiltM.- FilterM can process the signal in backward direction. (This is the main part of the acceleration of FiltFiltM, because it avoids to reverse the signal two times.)- For signals of type SINGLE, the intermediate values are stored in DOUBLE precision to increase the accuracy. The output is converted to SINGLE again.- The Signal Processing Toolbox is *not* needed.CALLING: Y = FiltFiltM(b, a, X, Dim) [Y, Zf] = FilterM(b, a, X, Zi, Dim, Reverse) b, a: Filter parameters as DOUBLE vectors. X: Signal as DOUBLE or SINGLE vector or array. Zi, Zf: Initial and final conditions as DOUBLE or SINGLE array. Optional, default: Zeros. Dim: Dimension to operate on. Optional, default: 1st non-singelton. Reverse: Flag to process the signal in reverse direction. Optional, default: FALSE. Y: Filtered signal, same size and type as X. While FilterM filters in forward direction, FiltFiltM processes the signal forward and reverse direction for a zero phase distortion.INTENTION:To accelerate my FEX submission FiltFiltM, I've implemented a filter asC-Mex, which works in reverse order. To my surprise this was faster thanrunning Matlab's FILTER forward, e.g. 3.7 times for a [10000 x 1] vector, 5th order Butterworth filter (Matlab 2009a, WinXP 32 bit, single core). Therefore I've expanded the Mex such that the direction can be definedas input. The algorithm is a direct form II transposed structure.A future version will be mutli-threaded.INSTALLATION:Setup the compiler if not done before: mex -setup.Auto-compilation: Call FilterM without inputs to start the compilation.A pre-compiled Mex can be downloaded: http://www.n-simon.de/mexRun the unit-tests uTest_FilterM and uTest_FiltFiltM to check validity and speed.Tested: Matlab 6.5, 7.7, 7.8, WinXP, 32bit Compiler: LCC2.4/3.8, BCC5.5, OWC1.8, MSVC2008Assumed Compatibility: higher Matlab versions, Mac, Linux, 64bitThis is faster and more powerful than my former submission "FiltFiltM", which will be removed soon.

L-BFGS-B is a collection of Fortran 77 routines for solving nonlinear optimization problems with bound constraints on the variables. One of the key features of the nonlinear solver is that the Hessian is not needed. I've designed an interface to the L-BFGS-B solver so that it can be called like any other function in MATLAB.

Simply convert between hex color values and rgb color values. These two functions can handle arrays as inputs. Default rgb values are scaled from 0 to 1 to match Matlab's syntax. However, if you'd like to use RGB values scaled from 0 to 255, that'll work too. SYNTAX:rgb = hex2rgb(hex) returns rgb color values in an n x 3 array. Values are scaled from 0 to 1 by default. rgb = hex2rgb(hex,255) returns RGB values scaled from 0 to 255. * * * * * * * * * * * * * * * * * * * * EXAMPLES: myrgbvalue = hex2rgb('#334D66') = 0.2000 0.3020 0.4000myrgbvalue = hex2rgb('334D66') % <-the # sign is optional = 0.2000 0.3020 0.4000myRGBvalue = hex2rgb('#334D66',255) = 51 77 102myhexvalues = ['#334D66';'#8099B3';'#CC9933';'#3333E6'];myrgbvalues = hex2rgb(myhexvalues) = 0.2000 0.3020 0.4000 0.5020 0.6000 0.7020 0.8000 0.6000 0.2000 0.2000 0.2000 0.9020myhexvalues = ['#334D66';'#8099B3';'#CC9933';'#3333E6'];myRGBvalues = hex2rgb(myhexvalues,255) = 51 77 102 128 153 179 204 153 51 51 51 230********************************************************THE OTHER FUNCTION********************************************************SYNTAX:hex = rgb2hex(rgb) returns the hexadecimal color value of the n x 3 rgb values. rgb can be an array. This function assumes rgb values are in [r g b] format on the 0 to 1 scale. If, however, any value r, g, or b exceed 1, the function assumes [r g b] are scaled between 0 and 255. * * * * * * * * * * * * * * * * * * * * EXAMPLES: myhexvalue = rgb2hex([0 1 0]) = #00FF00myhexvalue = rgb2hex([0 255 0]) = #00FF00myrgbvalues = [.2 .3 .4; .5 .6 .7; .8 .6 .2; .2 .2 .9];myhexvalues = rgb2hex(myrgbvalues) = #334D66 #8099B3 #CC9933 #3333E6

# PIVlab - particle image velocimetry (PIV) tool with GUI*PIVlab is a graphical user interface (GUI) based particle image velocimetry (PIV) software. It can be used to control OPTOLUTION's lasers, cameras and synchronizers, and of course it calculates the velocity distribution within imported (or captured) particle image pairs. It can also be used to derive, display and export multiple parameters of the flow pattern. The simple, GUI makes PIV data acquisition and data post-processing fast and efficient.*Listen to a podcast about PIVlab, its development and ideas for the future: [Inspiring Computing - PIVlab Unveiled: A Deep Dive into Particle Image Velocimetry with MATLAB](https://www.buzzsprout.com/2107763/15106425)![PIVlab_screenshot](https://github.com/Shrediquette/PIVlab/blob/main/images/PIVlab_screenshot.jpg)** ****PIVlab comes with it's own unique hardware: Pulsed lasers, LEDs, synchronizers and cameras are available here: [Optolution.com](https://www.optolution.com/en/products/particle-image-velocimetry-piv/)**** **Video tutorial 1/3: Quickstart guidehttps://youtube.com/watch?v=g2hcTRAzBvYVideo tutorial 2/3: Pre-processing, analysis and data validationhttps://youtube.com/watch?v=15RTs_USHFkVideo tutorial 3/3: Data exploration and data exporthttps://youtube.com/watch?v=47NCB_RFiE8PIVlab controlling cameras, lasers, etc.https://youtu.be/8B5M31NWlJc**Installation:** https://github.com/Shrediquette/PIVlab/wiki#installation-instructions**Please ask your questions in the PIVlab forum:** http://pivlab.blogspot.de/p/forum.html**Software documentation is available in the wiki:** https://github.com/Shrediquette/PIVlab/wiki** ****Code contributors:*** Main: William Thielicke (http://william.thielicke.org)* Name spaces / packages: Mikhil from MATHWORKS (https://github.com/Mikhil11)* Vectorization in piv_fftmulti: Sergey Filatov (http://www.issp.ac.ru/lqc/people.html)* GUI parallelization: Chun-Sheng Wang, ParaPIV (https://de.mathworks.com/matlabcentral/fileexchange/63358-parapiv)* Command line parallelization: Quynh M. Nguyen (https://github.com/quynhneo)* Speed, memory and general optimizations: Maarten (https://github.com/mkbosmans) via VORtech.nl via MathWorks** **We would like to acknowledge Uri Shavit, Roi Gurka & Alex Liberzon for sharing their code for 3-point Gaussian sub-pixel estimation. Thanks to Nima Bigdely Shamlo for allowing me to include the LIC function. Thanks to Raffel et al. for writing the book "Particle Image Velocimetry, A Practical Guide", which was a very good help. Thanks to the [thousands of publications that use PIVlab for research](https://scholar.google.de/scholar?cites=819244312015141543)!Visit Matlabs File exchange site for PIVlab: [![View PIVlab - particle image velocimetry (PIV) tool on File Exchange](https://www.mathworks.com/matlabcentral/images/matlab-file-exchange.svg)](https://de.mathworks.com/matlabcentral/fileexchange/27659-pivlab-particle-image-velocimetry-piv-tool)PIVlab [can be run online using MATLAB online](https://youtu.be/EQHfAmRxXw4?si=X77HabqAIbuHRIGT). MATLAB online is free (after registration) with a limited usage time per user (20 hrs/month):[![Open in MATLAB Online](https://www.mathworks.com/images/responsive/global/open-in-matlab-online.svg)](https://matlab.mathworks.com/open/github/v1?repo=Shrediquette/PIVlab&file=PIVlab_GUI.m)

VChooseKR(V, K) creates a matrix, which rows are all combinations created by choosing K elements of the vector V without order and with repetitions.INPUT: V: Array of class DOUBLE, SINGLE, (U)INT8/16/32/64, LOGICAL, CHAR. Prefer (U)INT8 or (U)INT16 for speed. K: Number of elements to choose.OUTPUT: Y: Matrix of size [(N+K-1 over K), K] and same class as V.EXAMPLES: Choose 2 elements from [1,2,3,4]: VChooseKR(1:4, 2) ==> [1,1; 1,2; 1,3; 1,4; 2,2; 2,3; 2,4; 3,3; 3,4; 4,4] For speed cast the input to integer types if possible: Y = VChooseKR(int8(1:64), 3) is 6 times faster than with DOUBLEs! To get the combinations of cell arrays, use the combinations of the index: C = {'a', 'b', 'c', 'd'}; C2 = C(VChooseKR(1:4, 2)) ==> C2 = {'a','a'; 'a','b'; 'a','c'; 'a','d'; 'b','b'; 'b','c'; ... 'b','d'; 'c','c'; 'c','d'; 'd','d'}This MEX version is faster than COMBINATOR of Matt Fig: E.g. ~7 times for K=64, N=2, ~140 times for K=2, N=128. The older PICK of Stefan Stoll is slower than COMBINATOR. See screen shot.Tested: Matlab 6.5, 7.7, 7.8, WinXP, Compilers: BCC5.5, LCC2.4/3.8, Open Watcom 1.8Please run the unit-test TestVChooseKR after compiling or to compare the speed with other functions from the FEX, if they are found in the path.See also: VChooseK (no repetitions, no order): http://www.mathworks.com/matlabcentral/fileexchange/26190VChooseKRO (repetitions, order): http://www.mathworks.com/matlabcentral/fileexchange/26242I'd appreciate suggestions for improvements and bug reports sent through email - thanks.

MATLAB 7.7 (R2008b) and above do not support using FWRITE to write numeric data in VAXD and VAXG formats. VAX architecture supports two methods for representing floating point double precision (64bit) numbers. These two methods are called VAXD and VAXG. Additionally, VAX supports a method called VAXF for representing single precision (32bit) floating point numbers. For detailed information on VAX encoding, please refer to: http://www.opengroup.org/onlinepubs/9629399/chap14.htm#tagfcjh_20There are two options to patch your code:Option A:----------- 1. Open your file with the 'ieee-le' format instead of 'vaxd' or 'vaxg'. 2. Replace FWRITE commands with FWRITEVAX. Pass 'vaxd' or 'vaxg' as an input argument.For example, if your code originally looks like this:fid = fopen(‘filename’, ‘w’, ‘vaxd’)countA = fwrite(fid, varA, ‘single’)countB = fwrite(fid, varB, 'double')You would change your code to:fid = fopen('vaxFileName', 'w', 'ieee-le') countA = fwriteVAX(fid, varA, ‘single’)countB = fwriteVAX(fid, varB, ‘double’, 'vaxd') Option B:----------- 1. Open your file with the 'ieee-le' format instead of 'vaxd' or 'vaxg'. 2. Replace FWRITE commands with FWRITEVAXD or FWRITEVAXG. For example, if your code originally looks like this:fid = fopen(‘filename’, ‘w’, ‘vaxd’)countA = fwrite(fid, varA, ‘single’)countB = fwrite(fid, varB, 'double')You would change your code to:fid = fopen('vaxFileName', 'w', 'ieee-le')countA = fwriteVAXD(fid, varA, ‘single’)countB = fwriteVAXD(fid, varB, 'double')Contains:1. fwriteVAX.m: Call this function from your program to write to a binary file using VAX format. 2. fwriteVAXD.m Call this function from your program to write to a binary file using VAXD format. 3. fwriteVAXG.m Call this function from your program to write to a binary file using VAXG format. 4. VAXF_to_uint32le.m: To be called internally from fwriteVAX, fwriteVAXD and fwriteVAXG.5. VAXD_to_uint64le.m: To be called internally from fwriteVAX, fwriteVAXD and fwriteVAXG.6. VAXG_to_uint64le.m: To be called internally from fwriteVAX, fwriteVAXD and fwriteVAXG.7. readme.pdf: This file.Please see the following submission for reading data stored in VAX file format using MATLAB 7.7 (R2008b) and later releases: http://www.mathworks.com/matlabcentral/fileexchange/22675

VChooseKRO(V, K) creates a matrix, which rows are all permutations created by choosing K elements of the vector V with order and with repetitions.INPUT: V: Array of class DOUBLE, SINGLE, (U)INT8/16/32/64, LOGICAL, CHAR. Prefer (U)INT8 or (U)INT16 for speed. K: Number of elements to choose.OUTPUT: Y: Matrix of size [NUMEL(V)^K, K]. Y has the same class as the input V.EXAMPLES: Choose 2 elements from [1,2,3]: VChooseKRO(1:3, 2) ==> [1,1; 1,2; 1,3; 2,1; 2,2; 2,3; 3,1; 3,2; 3,3] For speed cast the input to integer types if possible: Y = double(VChooseKRO(int16(1:1000), 2)); is faster than: Y = VChooseKRO(1:1000, 2); To get the permutations of cell arrays, permute the index: C = {'a', 'b', 'c', 'd'}; C2 = C(VChooseKRO(1:4, 2)) ==> C2 = {'a', 'b'; 'a', 'c'; 'a', 'd'; 'b', 'c'; 'b', 'd'; 'c', 'd'}This MEX version is faster than NPERMUTEK and the more general COMBINATOR of Matt Fig: ~8 times for small arrays, ~2 times for (N=2000, K=2), ~10 times for (N=2, K=16, Class=INT8). COMBN of Jos is again slower than Matt's functions and it does not handle INT classes. See screen shot.Tested: Matlab 6.5, 7.7, 7.8, WinXP, Compilers: BCC5.5, LCC2.4/3.8, Open Watcom 1.8The unit-test TestVChooseKRO should be called after compiling. It compares the speed of VChooseKRO with COMBN, NPERMUTEK and COMBINATOR, if these files are found in the path.See also: VChooseK (no repetitions, no order): http://www.mathworks.com/matlabcentral/fileexchange/26190I'd appreciate suggestions for improvements and bug reports sent through email - thanks.

DATESTR2NUM - Fast conversion of DATESTR to DATENUMThe builtin DATENUM command is very powerful, but if the input is known to be valid and formatted exactly, a specific MEX can be much faster:For single strings DateStr2Num is about 120 times faster than DATENUM, for a {1 x 10000} cell string, the speed up factor is 300 to 600(!), (Matlab 2011b/64, MSVC 2008).D = DateStr2Num(S, F)INPUT: S: String or cell string in DATESTR(F) format. In opposite to DATENUM the validity of the input string is *not* checked. F: Integer number defining the input format. Accepted: 0: 'dd-mmm-yyyy HH:MM:SS' 01-Mar-2000 15:45:17 1: 'dd-mmm-yyyy' 01-Mar-2000 29: 'yyyy-mm-dd' 2000-03-01 30: 'yyyymmddTHHMMSS' 20000301T154517 31: 'yyyy-mm-dd HH:MM:SS' 2000-03-01 15:45:17 230: 'mm/dd/yyyyHH:MM:SS' 12/24/201515:45:17 231: 'mm/dd/yyyy HH:MM:SS' 12/24/2015 15:45:17 240: 'dd/mm/yyyyHH:MM:SS' 24/12/201515:45:17 241: 'dd/mm/yyyy HH:MM:SS' 24/12/2015 15:45:17 1000: 'dd-mmm-yyyy HH:MM:SS.FFF' 01-Mar-2000 15:45:17.123 1030: 'yyyymmddTHHMMSS.FFF' 20000301T154517.123OUTPUT: D: Serial date number.EXAMPLE: C = {'2010-06-29 21:59:13', '2010-06-29 21:59:13'}; D = DateStr2Num(C, 31) >> [734318.916122685, 734318.916122685] Equivalent Matlab command: D = datenum(C, 'yyyy-mm-dd HH:MM:SS')The C-file must be compiled before using. This is done automatically at the first call of this function.Pre-compiled Mex files can be downloaded from: http://www.n-simon.de/mexTested: Matlab 6.5, 7.7, 7.8, 7.13, 32/64bit, WinXP/7Compiler: LCC 2.4/3.8, BCC 5.5, Open Watcom 1.8, MSVC 2008 Compatibility to MacOS, Linux, 64 bit is assumed, but not tested.See also: DateConvert (Jan Simon) http://www.mathworks.com/matlabcentral/fileexchange/25594

This is a simple implementation of the Henon system. It is a discrete time system that maps a point $(x_n,y_n)$ in the following fashion: $x_{n+1}=1-a x_n^2 + y_n$ $y_{n+1}=b x_n$Where a and b are the system parameters.This script computes 10000 iterations fora=1.4 and b=0.3.This file also includes a .pdf file created with the publish feature. The comments on the file are created in a fashion that an html format will work great.This is included in [1]. References: [1] An introduction to Control Theory Applications Using Matlab, https://www.researchgate.net/publication/281374146_An_Introduction_to_Control_Theory_Applications_with_Matlab[2] Moysis, L., & Azar, A. T. (2017). New Discrete Time 2D Chaotic Maps. International Journal of System Dynamics Applications (IJSDA), 6(1), 77-104. http://www.igi-global.com/article/new-discrete-time-2d-chaotic-maps/169799

WINDOWS MEXING WITH MATLAB 7.6 AND 7.7 (AND PROBABLY OTHERS) WITH IFORT 11.0 This submission contains three files that enable mexing with version 11.0 of ifort. The files should be copied to the folder: c:\program files\matlab\r20xyz\bin\win32\mexopts(where r20xyz could for example be r2008a or r2008b), and the two files with extension .b should be renamed to have extension.bat (Matlab central regulations do not allow .bat files). These files are updated from the version 10.1 files.Then mex -setup should work.NOTE: The default location of ifort.exe has changed between versions 10.xxx and version 11 of the ifort compiler from: C:\Program Files\Intel\Compiler\Fortran\10.1.011\IA32\Binto: C:\Program Files\Intel\Compiler\11.0\066\Fortran\Bin\IA32Note in particular that the order of Bin and IA32 has been reversed. The include and lib folders have also new locations. To create .stp and .bat files for other subversions of ifort 11, make copies of the files and appropriate changes in both of them (search for the version number, "11.0").To support other subversions of version 10 than 10.1.011 make copies of the files intelf10msvs2005opts.bat and intelf10msvs2005opts.stp and make the necessary changes in them (change e.g. 10.1.012 to 10.1.021). It is probably also possible to create similar files for versions 8.x and 9.x of the compiler.NOTE 1: There are some similar files by C.Chee on Matlab Central that inspired me for these, see http://www.mathworks.com/matlabcentral/fileexchange/18563.NOTE 2: For mexing with gcc, gfortran and g95, see http://sourceforge.net/projects/gnumexNOTE 3: I have not tested the intelf11msvs2005engmatopts.bat (for building engine applications).NOTE 4: One more change I have made to the bat file is to remove the /fixed flag from the compiler flags to allow free form input. In theory this should allow Fortran 95 programs in free format to be turned into mex files, but for some reason my short test file does not currently work (although my Fortran 77 test does work). I have not had time to look into this further.Nov.2008. Kristjan Jonasson (jonasson@hi.is)

Modeling tools are useful for educational and industrial use. Such tools help the new engineers to simulate the power system under normal and faulty conditions. This simulation presents the design and various data conversion steps of a digital negative sequence relay. The relay performance under different system dynamics is also visualized on MATLAB / SIMULINK® considering a 400V power system.This is an authorized work. Any modification in simulation need citation of work or prior permission from author.Reference paper:M.M. Aman, G.B. Jasmon, Q.A. Khan, A.H.B.A. Bakar, M.N. Abdullah, Modeling and simulation of digital negative sequence relay for unbalanced protection of generator, in: Power Engineering and Optimization Conference (PEDCO) Melaka, Malaysia, 2012 Ieee International, 2012, pp. 72-77.

XSum - SUM with error compensationThe accuracy of the sum of floating point numbers is limited by the truncation error. E.g. SUM([1e16, 1, -1e16]) replies 0 instead of 1 and the error of SUM(RANDN(N, 1)) is about EPS*(N / 10).Kahan, Knuth, Dekker, Ogita and Rump (and others) have derived some methods to reduce the influence of rounding errors, which are implemented here as fast C-Mex: XSum(RANDN(N, 1), 'Knuth') is exact to all 15 digits.Y = XSum(X, N, Method)INPUT: X: Double array of any size. N: Dimension to operate on. Method: String: 'Double', 'Long', 'Kahan', 'Knuth', 'KnuthLong', 'Knuth2'.OUTPUT: Y: Double array, equivalent to SUM, but with compensated error depending on the Method. The high-precision result is rounded to double precision.METHODS: (speed and accuracy compared to SUM)- Double: A single threaded implementation of Matlab's SUM. At least in Matlab 2008a to 2009b the results of the multi-threaded SUM can differ slightly from call to call. Equivalent accuracy. 1.1 to 2 times slower than SUM.- Long: Accumulated in a 80 bit long double, if the compiler support this (e.g. LCC v3.8). 3.5 more valid digits, 2 times slower.- Kahan: The local error is subtracted from the next element. 1 to 3 more valid digits, 2 to 9 times slower.- Knuth: As if the sum is accumulated in a 128 bit float: about 15 more valid digits. 1.4 to 4 times slower. This is suitable for the most real world problems.- Knuth2: 30 more valid digits as if it is accumulated in a 196 bit float. 2 to 8 times slower.- KnuthLong: As Knuth, but using long doubles to get about 21 more valid digits, if supported by the compiler. 2.5 times slower.COMPILATION: mex -O XSum.cTested: Matlab 6.5, 7.7, 7.8, WinXP, BCC5.5, LCC2.4/3.8, Open Watcom 1.8, MSVC++ 2008TestXSum checks the validity, speed and accuracy after compiling (see screen shot).Pre-compiled MEX files: http://www.n-simon.de/mexReferences: Takeshi Ogita and Siegfried M. Rump and Shin'ichi Oishi: "Accurate Sum and Dot Product with Applications"See also: INTLAB, S. M. Rump: http://www.ti3.tu-harburg.de/rump/intlab

C-Mex: anyEqThis is a simple but fast check, if two arrays contain any common element.The C-Mex is 25% to 60% faster than the equivalent Matlab expression "any(X(:) == y)" and much faster than "any(ismember(X, Y))" if Y is an array.If a matching element is found early, this function returns very fast without testing the rest.In opposite to the Matlab version, the C-mex does not need any temporary arrays.R = anyEq(X, Y)INPUT: X, Y: Arrays of any size. Complex or sparse array are rejected. Types: DOUBLE, SINGLE, (U)INT8/16/32/64, CHAR, LOGICAL.OUTPUT: R: TRUE is replied if any element of X occurs in Y, FALSE otherwise.NOTES:- This is equivalent to: R = any(X(:) == Y(1)) || any(X(:) == Y(2)) || ...- This MEX version is faster than the Matlab method, because the creation of the intermediate logical array is avoided: Worst case (no matching element): 25% to 60% faster Best case (first element matches): 99.99% faster for 1e6 elements (Matlab 2011b/64, MSVC 2008).- For small LOGICAL arrays (< 5'000 elements) anyEq is up to 65% slower than any(X) or ~all(X). For larger arrays the speedup depends on the position of the first match and can reach a factor of 7.- X and Y are ordered automatically such, that the elements of the smaller array are searched in the larger one.EXAMPLES: anyEq(0:0.1:1, 0.3) % FALSE: Effect of limited precision anyEq(1:4, [5,2]) % TRUE: 2 is found in 1:4COMPILATION: See anyEq.c for instructions how to compile the C-file.TEST: Run uTest_anyEq to check validity and speed of the Mex function.Tested: Matlab 6.5, 7.7, 7.8, 7.13, WinXP/32, Win7/64 Compiler: LCC2.4/3.8, BCC5.5, OWC1.8, MSVC2008/2010Suggestion and bugreports by email or in the comment section are appreciated.

This repository was created for anybody interested in using feature selection (ReliefF, Matlab: relieff) and support vector machines (SVM, Matlab: fitcsvm) as a minimum working example to reproduce steps described in the publication below (Doerr2020). Data is provided in the sub-folder '_Data'. Structural features were extracted from micro-X-ray tomography data. ReliefF and SVM were used to build a classifier for the detection of broken pharmaceutical pellets within the sample.Input Data:(1) Extracted features of six ibuprofen (IBU) capsules (1763 pellets, 206 features): 'Desc_DataFile_C0.csv' 'Desc_DataFile_C1.csv' 'Desc_DataFile_C2.csv' 'Desc_DataFile_C3.csv' 'Desc_DataFile_C4.csv' 'Desc_DataFile_C5.csv'(2) User defined feature categories: 'Feature_Categories.csv'(3) Results of a feature sensitivity analysis: 'Feature_SenAnlys_Score.csv'%------------------------------------------------------------------------------------------------% Code written by Frederik Doerr, Feb 2020 (MATLAB R2019b)% Application: For 'Support Vector Machine - Introduction and Application'% % % Reference (open access):% Doerr, F. J. S., Florence, A. J. (2020)% A micro-XRT image analysis and machine learning methodology for the characterisation of multi-particulate capsule formulations. % International Journal of Pharmaceutics: X. % https://doi.org/10.1016/j.ijpx.2020.100041% Data repository: https://doi.org/10.15129/e5d22969-77d4-46a8-83b8-818b50d8ff45% Video Abstract: https://strathprints.strath.ac.uk/id/eprint/71463%------------------------------------------------------------------------------------------------

VChooseKO(V, K) creates a matrix, which rows are all permutations of choosing K elements of the vector V with order and without repetitions.INPUT: V: Array of class DOUBLE, SINGLE, (U)INT8/16/32/64, LOGICAL, CHAR. K: Number of elements to choose.OUTPUT: Y: [N!/(N-K)!, K] matrix with N is the number of elements of V. Y has the same class as the input V. The rows are sorted in lexicographical order: smaller indices at first.EXAMPLES: Choose 2 elements from [1, 2, 3]: VChooseKO(1:3, 2) % ==> [1,2; 1,3; 2,1; 2,3; 3,1; 3,2] For speed cast the input to integer types or SINGLE whenever possible: Y = VChooseKO(uint8(1:100), 3); % 5 times faster than: Y = VChooseKO(1:100, 3); To get the permutations of cell arrays, permute the index: C = {'a', 'b', 'c', 'd'}; C2 = C(VChooseKO(uint8(1:4), 2)) ==> C2 = {'a','b'; 'a','c'; 'a','d'; 'b','a'; 'b','c'; 'b','d'; ... 'c','a'; 'c','b'; 'c','d'; 'd','a'; 'd','b'; 'd','c'} Equivalent to PERMS: isequal(sortrows(perms(1:5)), VChooseKO(1:5, 5)) % TRUE For an output with sorted values (not indices!), sort the input: X = [3, 1, 2]; VChooseKO(sort(X), 3) ==> [1,2,3; 1,3,2; 2,1,3; 2,3,1; 3,1,2; 3,2,1]The output of VCHOOSEKO(V, K) is equivalent to COMBINATOR(NUMEL(V), K, 'p'), but is remarkably faster (see screenshot). The lexicographical output of VCHOOSEKO can be a benefit also, because a time-consuming SORTROWS can be omitted.Tested: Matlab 6.5, 7.7, 7.8, WinXP, 32 bit, Compilers: BCC5.5, LCC2.4/3.8, Open Watcom 1.8The unit-test function TestVChooseKO is included to test the validitiy and compare the speed with PICK, COMBINATOR and Matlab's PERMS.Precompiled mex: http://www.n-simon.de/mexSee also: VChooseK (no repetitions, no order): FEX #26190 VChooseKRO (repetitions, order): FEX #26242 VChooseKR (repetitions, no order): FEX #26277I'd appreciate suggestions for improvements and bug reports sent through email - thanks.

This FEX submission offers a tool set for fitting and plotting 2D conics (ellipses, circles, lines,...) as well as 3D quadric surfaces (ellipsoids, spheres, planes, cylinders, cones,...). Each type of fit is represented by an object within a class hierarchy. For each fit type, overloaded methods are provided for fitting the data, as well as post-plotting an overlay of the fit onto the raw data in a style similar to the Curve Fitting Toolbox. There are also methods for re-sampling the fit at a user-selected set of points. Finally, the tools allow one to construct "ground truth" objects representing a conic/quadric with pre-selected parameters. This makes it possible to simply plot a desired ellipse or other supported shape regardless of whether it arises from a fitting process at all.Currently, not all curve/surface types in the conic/quadric family are covered by this tool set, although I may add more over time. For now, I provide a subset of the ones that seem to be the most commonly encountered. Similarly, most fitting algorithms used by the tool set are very basic algebraic methods, although I may add more refined algorithms as the need and interest arise.Various example uses of these tools are illustrated in the Examples tab.

Join 2 or 3 strings and cell strings 10 times faster than STRCAT R = CStrCatStr(A, B) or R = CStrCatStr(A, B, C)INPUT: A, B, C: Strings or cell strings. At least one input must be a cell string.OUTPUT: R: Cell string with the same size as the input cell.Comparison with Matlab's STRCAT:- MEX version is about 10 times faster that STRCAT.- CStrCatStr is limited to 2 or 3 inputs with at least one cell string.- CStrCatStr conserves marginal spaces.- STRCAT('A', {}) replies: {'A'}. CStrCatStr('A', {}) replies: {}.- CStrCatStr treats char arrays as single string with linear index.EXAMPLES: CStrCatStr('a', {'a', 'b', 'c'}) % ==> {'aa', 'ab', 'ac'} CStrCatStr({'a'; 'b'; 'c'}, '-') % ==> {'a-'; 'b-'; 'c-'} CStrCatStr({' ', ''}, 'a', {' ', ''}) % ==> {' a ', 'a'} CStrCatStr({'a', 'b'}, {'c'}) % ==> error: cells need equal size FileDir = dir(Path); AbsName = CStrCatStr(Path, filesep, {FileDir.name});Tested: Matlab 6.5, 7.7, 7.8, Win2K/XP, LCC2.4, LCC3.8, BCC5.5, 32 + 64 bit addressing.Run unit-test TestCStrCatStr after compiling and for a speed test (see screen shot).Compiled Mex: http://www.n-simon.de/mex

It can be used to put an array inside another array at an arbitrary location. It is sensitive to edges and correctly crops as needed.Example: A = zeros(10);B = rand(5);ij = [7,7];I = insertImage(A, B, ij);figure,imagesc(I)axis equal tight

Syntax: [bindingsList, actionsList] = EditorMacro(keystroke, macro, macroType) [bindingsList, actionsList] = EditorMacro(bindingsList) Description: EditorMacro assigns the specified MACRO to the requested keyboard KEYSTROKE, within the context of the Matlab Editor and Command Window. KEYSTROKE is a string representation of the keyboard combination. Special modifiers (Alt, Ctrl or Control, Shift, Meta, AltGraph) are recognized and should be separated with a space, dash (-), plus (+) or comma (,). If KEYSTROKE was already defined, then it will be updated (overridden). MACRO should be in one of Matlab's standard callback formats: 'string', @FunctionHandle or {@FunctionHandle,arg1,...}, or any of several hundred built-in editor action-names - read MACROTYPE below for a full description. To remove a KEYSTROKE-MACRO definition, simply enter an empty MACRO ([], {} or ''). MACROTYPE is an optional input argument specifying the type of action that MACRO is expected to do: - 'text' (=default value) indicates that if the MACRO is a: 1. 'string': this string will be inserted as-is into the current editor caret position (or replace selected editor text). Multi-line strings can be set using embedded \n's. 2. @FunctionHandle - the specified function will be invoked and is expected to return a string which will then be inserted into the editor document as expained above. 3. {@FunctionHandle,arg1,...} - like #2, but the function will be called with the specified args. - 'run' indicates that MACRO should be invoked as a Matlab command, just like any regular Matlab callback. The accepted MACRO formats and function input args are exactly like for 'text' above, except that no output string is expected and no text insertion/replacement will be done, useful for non-textual actions. In addition, this MACROTYPE accepts all available (built-in) editor action names. Valid action names can be listed by requesting the ACTIONSLIST output arg. BINDINGSLIST = EditorMacro returns the list of currently-defined KEYSTROKE bindings as a 4-columned cell array:{keystroke,macro,type,class}. The class information indicates a built-in action ('editor menu action', 'editor native action', 'cmdwin native action' or 'cmdwin menu action') or a user-defined action ('text' or 'user-defined macro'). BINDINGSLIST = EditorMacro(KEYSTROKE) returns the bindings list for the specified KEYSTROKE as a 4-columned cell array: {keystroke, macro, type, class}. BINDINGSLIST = EditorMacro(KEYSTROKE,MACRO) returns the bindings list after defining a specific KEYSTROKE-MACRO binding. EditorMacro(BINDINGSLIST) can be used to set a bunch of key bindings using a single command. BINDINGSLIST is the cell array returned from a previous invocation of EditorMacro, or by manual construction. [BINDINGSLIST, ACTIONSLIST] = EditorMacro(...) returns in ACTIONSLIST a 3-columned cell array of all available built-in actions and currently-associated key-biding(s): {actionName, keyBinding(s), class}. Usage Examples: bindingsList = EditorMacro; % get list of current key-bindings bindingsList = EditorMacro('ctrl r'); % get list of bindings for -R [bindings,actions] = EditorMacro; % get list of available built-in action-names EditorMacro('Ctrl Shift C', '%%% Main comment %%%\n% \n% \n% \n'); EditorMacro('Alt-x', 'try\n % Main code here\ncatch\n % Exception handling here\nend'); EditorMacro('Ctrl-Alt C', @myCallbackFunction); % myCallbackFunction returns a string to insert EditorMacro('Alt control t', @(a,b)datestr(now), 'text'); % insert current timestamp EditorMacro('Shift-Control d', {@computeDiameter,3.14159}, 'run'); EditorMacro('Alt L', 'to-lower-case', 'run') % Built-in action: convert text to lowercase EditorMacro('ctrl D','open-selection','run') % Override default Command-Window action (=delete) to behave as in the Editor (=open selected file) A few known limitations (=TODO for future versions) are listed within the file's help section. Bugs and suggestions: EditorMacro was tested on Matlab 6.0 (R12) through 7.7(R2008b). Note: Unfortunately, my Matlab 6 computer crashed since the first version so I can no longer test EditorMacro on Matlab 6, so if you find problems please email me directly. Please send bugs to Yair Altman (altmany at gmail dot com) Warning: This code heavily relies on undocumented and unsupported Matlab functionality. It works on Matlab 6 & 7+, but use at your own risk! A technical description of the implementation can be found at: http://UndocumentedMatlab.com/blog/EditorMacro/

Convert the numerical format of C3Ds from VaxD ("Dec") to IEEE-LE ("PC")C3D is a file format commonly used in biomechanics and motion analysis. Floating point numbers can be stored in 3 different ways in C3D files: VAX-D, IEEE-LE and IEEE-BE (Vicon calls them DEC, PC and MIPS). Several Matlab routines to read C3D files can be found in the WWW, but unfortunately Matlab >= 2008b (v7.7) does not open files in VAX-D format anymore. This function converts C3D files written from VAX-D to IEEE-LE files (PC style) and works under Matlab 6 and 7. This function does not import the contents of the C3D files to Matlab!Calling:VAXD = C3D_VaxD2PC(Mode, FileSpec)Depending on the input [Mode] the files are only checked or converted. In addition either a single file or all files in a folder and all subfolders can be processed.Backups of the VAX-D files are created as ".c3d.vaxd" during the conversion. The original file is patched by changing the binary representation of all float32 numbers. Integers do not need a conversion and double64 numbers do not appear in C3D files.Example 1: Check all C3D files in the current folder and subfolders: VAXDFiles = C3D_VaxD2PC('CheckFolder', cd);Example 2: Convert one file (insert a file name): isVAXD = C3D_VaxD2PC('ConvertFile', );The function has been tested with Vicon-C3Ds only. Please feel free to contact me on problems.WARNING AND DISCLAIMER OF WARRANTY:Although no error appeared during the tests of this function, touching the expensive measurement files must be performed with care! Create a backup of all accessed files before!Tested: Matlab 6.5 and 2009a.

Function to read version 1 (classic 32bit) NetCDF files into a matlab structure.

Pandas<->MatlabThe functions are designed to convert Pandas DataFrames and Series to Matlab and back.Function df2t converts DataFrames and Series to Matlab in memory w/o saving anthing to the disk, while t2df converts Table to DataFrame.Make sure to set up Python in Matlabpe = pyenv;if pe.Status == "NotLoaded" [~,exepath] = system("where python"); pe = pyenv('Version',exepath);endCreate a simple dataframe from json and convert to TablejsonData = "{'gender': (['male'] * 6)+['female']," + ... "'name': ['Anton', 'Bill', 'Charlie', 'Don', 'Emil', 'Emil', 'Charlie']," +... "'eye_color': ['blue', 'green', 'green', 'green', 'blue', 'green', 'green']}";df = py.pandas.DataFrame(py.eval(jsonData, py.dict()));testTable = df2t(df);% plot the statisticsfigure("Color","white", "Position", [0,0,800,400])subplot(1,3,1), hist(categorical(testTable.gender))subplot(1,3,2), hist(categorical(testTable.name))subplot(1,3,3), hist(categorical(testTable.eye_color))Create a Table and convert it to DataFrame% then use Pandas to sample from it and create new dataframe, and convert it to TableName = {["Roger", "Sanchez"]; ["Paul", "Johnson"]; ["Lisa", "Li"]; ["Don", "Diaz"]; ["Havana ", "Brown"]};Age = [38;43;38;40;49];Smoker = logical([1;0;1;0;1]);Height = [71;69;64;67;64];Weight = [176;163;131;133;119];BloodPressure = [124 93; 109 77; 125 83; 117 75; 122 80];T = table(Name,Age,Smoker,Height,Weight,BloodPressure);T.BMI = (T.Weight * 0.453592)./(T.Height * 0.0254).^2;df = t2df(T);% Sample from the dataframedf_sampled = df.sample(int64(10), replace=true);table_sampled = df2t(df_sampled)Convert a Series to Table% Create a Series of random integers using numpy.random and convert to table rng = py.numpy.random.RandomState(int64(42));integers = rng.randint(int64(0), int64(10), int64(4));pySeries = py.pandas.Series(integers, pyargs('name', 'integers'));matSeries = df2t(pySeries)% Create a Series of random integers using Matlab rand with letters as indexes% and convert to Matlab.pySeries = py.pandas.Series(rand(1,4), pyargs('name', 'real','index', {'a', 'b', 'c', 'd'}));df2t(pySeries)% Create a Series of strings data_list = {"Jeff Bezos", "Elon Musk",... "Bernard Arnault", "Bill Gates", "Warren Buffett"};pySeries = py.pandas.Series(data_list, pyargs('name', 'Billioners','index', int64([1:numel(data_list)])));billioners = df2t(pySeries);billioners([2:3],:)Related Utilitiespy2mat.mandmat2py.mconvert generic Python variables to Matlab variables and vice versa.

Conversions of these routines into Matlab.From:http://pubs.usgs.gov/of/1995/ofr-95-0077/of-95-77.htmlAnderson, W.L, 1983, Fourier cosine and sine transforms using lagged convolutions in double-precision (Subprograms DLAGFO/DLAGF1): U.S. Geological Survey Open-File Report 83-320, 38 p. 026 DLAGF0/ DLAGF1 Fourier cosine/sine transforms (in double-precision). Numerical integration by lagged convolution. USGS Open-File Report 83-320 (1983) Fortran-77:VAX-11/780 (VMS) Subroutine Package%%%%%%%%%%%%%From the help:%C THE PURPOSE OF SUBPROGRAM DLAGF0 IS TO PROVIDE IN DOUBLE PRECISION%C A GENERAL ALGORITHM FOR FAST FOURIER COSINE TRANSFORMS OF THE FORM:%C INTEGRAL FROM 0 TO INFINITY OF FUN(G)*DCOS(B*G)*DG, WHERE WE LAG B%C IN[BMIN,BMAX]--USING IMPLIED VALUE OF BMIN=BMAX*DEXP(-.1*(NB-1)).%C%C DLAGF0 USES A NEW DOUBLE-PRECISION COSINE DIGITAL FILTER FOR USE%C IN LAGGED CONVOLUTION, WHERE THE ALGORITHM IS PATTERNED AFTER THE%C DOUBLE-PRECISION HANKEL TRANSFORM ROUTINE DHANKL PUBLISHED IN THE%C FOLLOWING REFERENCE:%C%C ANDERSON, W.L., 1982, FAST HANKEL TRANSFORMS USING RELATED AND LAGGED%C CONVOLUTIONS: ACM TRANS. ON MATH. SOFTWARE, V.8, N.4, P.344-368.%C%C DLAGF0 USES THE LAGGED CONVOLUTION METHOD IN THE ABOVE REFERENCE,%C BUT USES INTERNAL WORK ARRAYS DWORK(787) AND KEY(787)--INSTEAD OF%C PASSING DWORK IN THE CALLING SEQUENCE AS IN DHANKL. THE MINIMUM%C RELATIVE AND/OR ABSOLUTE ERRORS ARE ABOUT 10**-10 USING TOL<=10**-12.

To sort any file-names or folder-names use NATSORTFILES: http://www.mathworks.com/matlabcentral/fileexchange/47434-natural-order-filename-sortTo sort the elements of a string/cell array use NATSORT: http://www.mathworks.com/matlabcentral/fileexchange/34464-customizable-natural-order-sortSummaryAlphanumeric sort the rows of a string/cell/categorical/table array. Sorts the text by character code taking into account the values of any number substrings. Compare for example:>> X = {'x2','10';'x10','0';'x1','0';'x2','2'};>> sortrows(X) % Wrong numeric orderans = 'x1' '0' 'x10' '0' 'x2' '10' 'x2' '2'>> natsortrows(X) % Correct numeric orderans = 'x1' '0' 'x2' '2' 'x2' '10' 'x10' '0'By default NATSORTROWS interprets all consecutive digits as integer numbers, the number substring recognition can be specified using a regular expression: see NATSORT for details.File DependencyThe natural-order sort is provided by the function NATSORT (File Exchange 34464). All of NATSORT's optional inputs are supported by NATSORTROWS.Examples>> A = {'B','2','X';'A','100','X';'B','10','X';'A','2','Y';'A','20','X'};>> sortrows(A) % SORTROWS for comparison.ans = 'A' '100' 'X' 'A' '2' 'Y' 'A' '20' 'X' 'B' '10' 'X' 'B' '2' 'X'>> natsortrows(A)ans = 'A' '2' 'Y' 'A' '20' 'X' 'A' '100' 'X' 'B' '2' 'X' 'B' '10' 'X'>> natsortrows(A,[],'descend')ans = 'B' '10' 'X' 'B' '2' 'X' 'A' '100' 'X' 'A' '20' 'X' 'A' '2' 'Y'>> sortrows(A,[2,-3]) % SORTROWS for comparison.ans = 'B' '10' 'X' 'A' '100' 'X' 'A' '2' 'Y' 'B' '2' 'X' 'A' '20' 'X'>> natsortrows(A,[],[2,-3])ans = 'A' '2' 'Y' 'B' '2' 'X' 'B' '10' 'X' 'A' '20' 'X' 'A' '100' 'X'>> natsortrows(A,[],[false,true,true],{'ascend','descend'})ans = 'A' '2' 'Y' 'B' '2' 'X' 'B' '10' 'X' 'A' '20' 'X' 'A' '100' 'X'>> natsortrows(A,[],{'ignore','ascend','descend'})ans = 'A' '2' 'Y' 'B' '2' 'X' 'B' '10' 'X' 'A' '20' 'X' 'A' '100' 'X'T = cell2table(A);natsortrows(T,[], [2,-3]) % TABLEans = A1 A2 A3 ___ _____ ___ 'A' '2' 'Y' 'B' '2' 'X' 'B' '10' 'X' 'A' '20' 'X' 'A' '100' 'X'natsortrows(T,[], {'A2','A3'},{'ascend','descend'}) % TABLEans = A1 A2 A3 ___ _____ ___ 'A' '2' 'Y' 'B' '2' 'X' 'B' '10' 'X' 'A' '20' 'X' 'A' '100' 'X'>> B = {'ABCD';'3e45';'67.8';'+Inf';'-12';'+9';'NaN'};>> sortrows(B) % SORTROWS for comparison.ans = '+9' '+Inf' '-12' '3e45' '67.8' 'ABCD' 'NaN'>> natsortrows(B,'[-+]?(NaN|Inf|\d+\.?\d*(E[-+]?\d+)?)')ans = '-12' '+9' '67.8' '3e45' '+Inf' 'NaN' 'ABCD'>> C = {'A2', 2; 'A10', 1; 'A2', 1}; % Scalar numerics in a column:>> natsortrows(C,[],'sortnum')ans = 'A2' [1] 'A2' [2] 'A10' [1]>> natsortrows(C,[],'sortnum',{'ascend','descend'})ans = 'A2' [2] 'A2' [1] 'A10' [1]

checkClass inspects the specified Java, Matlab (MCOS), .NET, Python, C++ (CLib), or COM (ActiveX) object reference or class-name, and reports its superclass(es), interfaces, new/modified methods, super/sub-classes, properties, events, constants, enumerations and annotations.metadata = checkClass(...) returns a meta.class or meta.package object that encapsulates the input object.This utility complements the GUI-based UIINSPECT utility by being Command-Prompt based and also by highlighting the object components that were modified in the inspected class compared to its parent superclass. Syntax:checkClass(objectReference)checkClass(className)checkClass(..., level) % default level=1 % Note: changed default in v1.32!metadata = checkClass(...)Usage examples:% Java objects/classescheckClass('java.lang.String')checkClass(javax.swing.JButton)jButton = javax.swing.JButton('Click me!');jButton.checkClass; % or: checkClass(jButton)checkClass(com.mathworks.mwswing.MJToolBar)checkClass(com.mathworks.mde.desk.MLDesktop.getInstance)% Matlab (MCOS) objects/classes/packagescheckClass(gcf)checkClass('matlab.ui.Figure')checkClass matlab.ui.Figure % equivalent to abovecheckClass matlab.ui.control % package name (contains classes, sub-packages)% .NET objects/classes/packagescheckClass('NET.Assembly')checkClass(System.Diagnostics.Process.GetCurrentProcess)% Python objects/classes/modulescheckClass('py.inspect')checkClass(py.importlib.import_module('calendar'))Technical description: https://UndocumentedMatlab.com/articles/checkclassBugs and suggestions: Please send to Yair Altman (altmany at gmail dot com)

Syntax: oldAlpha = setFigTransparency(hFig, alpha, fadeDuration, blockingFlag) Description: setFigTransparency sets the figure hFig's transparency value. The entire figure window, including all internal menus, toolbars and components, is made transparent according to the alpha value. oldAlpha = setFigTransparency(...) returns the old transparency value of the specified figure, prior to its modification. This submission is based on an original idea implemented by Malcolm Lidierth in his MUtilities submission: http://www.mathworks.com/matlabcentral/fileexchange/28326-mutilitiesInput parameters: (all parameters are optional) hFig (default=gcf) - Handle(s) of the modified figure(s). If component handle(s) is/are specified, the containing figure(s) will be inferred and used. alpha (default=0.5) - Transparency value, between 0.0 (=fully transparent) and 1.0 (=fully opaque). Note that all Matlab figure windows are created opaque. alpha<0 indicates that alpha value should not be modified. fadeDuration (default=0) - Number of seconds for fade-in/fade-out effect. Note: default value of 0 means immediately (no fading) blockingFlag - (default=true) Whether or not the function should wait for the fade-in/fade-out effect to complete before returning Examples: oldAlpha = setFigTransparency(hFig,-1); % get hFig's current alpha oldAlpha = setFigTransparency(hFig); % set hFig's alpha to 0.5 (semi-transparent) oldAlpha = setFigTransparency(hFig,0.7); % set hFig's alpha to 0.7 oldAlpha = setFigTransparency([hFig1,hFig2],0.7); % set transparency for several figures oldAlpha = setFigTransparency(hFig,0.3,1.5,false); % non-blocking fade over 1.5 secsBugs and suggestions: Please send to Yair Altman (altmany at gmail dot com) Warning: This code heavily relies on undocumented and unsupported Matlab functionality. It works on Matlab 7.9 (R2009b) and higher, but use at your own risk!

To sort any file-names or folder-names use NATSORTFILES:http://www.mathworks.com/matlabcentral/fileexchange/47434-natural-order-filename-sortTo sort the rows of a string/cell array use NATSORTROWS:http://www.mathworks.com/matlabcentral/fileexchange/47433-natural-order-row-sortSummaryAlphanumeric sort the text in a string/cell/categorical array. Sorts the text by character code taking into account the values of any number substrings. Compare for example:X = {'a2', 'a10', 'a1'}; sort(X) ans = 'a1' 'a10' 'a2' natsort(X) ans = 'a1' 'a2' 'a10'By default NATSORT interprets all consecutive digits as integer numbers, the number substring recognition can be specified using a regular expression, allowing the number substrings to have: a +/- sign a decimal point and decimal fraction E-notation exponentdecimal, octal, hexadecimal or binary notation Inf or NaN values criteria supported by regular expressions: lookarounds, quantifiers, etc.And of course the sorting itself can also be controlled: ascending/descending sort directioncharacter case sensitivity/insensitivityrelative order of numbers vs. charactersrelative order of numbers vs NaNsExamples%% Multiple integers (e.g. release version numbers):>> A = {'v10.6', 'v9.10', 'v9.5', 'v10.10', 'v9.10.20', 'v9.10.8'};>> sort(A) % for comparison.ans = 'v10.10' 'v10.6' 'v9.10' 'v9.10.20' 'v9.10.8' 'v9.5'>> natsort(A)ans = 'v9.5' 'v9.10' 'v9.10.8' 'v9.10.20' 'v10.6' 'v10.10'%% Integer, decimal, NaN, or Inf numbers, possibly with +/- signs:>> B = {'test+NaN', 'test11.5', 'test-1.4', 'test', 'test-Inf', 'test+0.3'};>> sort(B) % for comparison.ans = 'test' 'test+0.3' 'test+NaN' 'test-1.4' 'test-Inf' 'test11.5'>> natsort(B, '[-+]?(NaN|Inf|\d+\.?\d*)')ans = 'test' 'test-Inf' 'test-1.4' 'test+0.3' 'test11.5' 'test+NaN'%% Integer or decimal numbers, possibly with an exponent:>> C = {'0.56e007', '', '43E-2', '10000', '9.8'};>> sort(C) % for comparison.ans = '' '0.56e007' '10000' '43E-2' '9.8'>> natsort(C, '\d+\.?\d*(E[-+]?\d+)?')ans = '' '43E-2' '9.8' '10000' '0.56e007'%% Hexadecimal numbers (with '0X' prefix):>> D = {'a0X7C4z', 'a0X5z', 'a0X18z', 'a0XFz'};>> sort(D) % for comparison.ans = 'a0X18z' 'a0X5z' 'a0X7C4z' 'a0XFz'>> natsort(D, '0X[0-9A-F]+', '%i')ans = 'a0X5z' 'a0XFz' 'a0X18z' 'a0X7C4z'%% Binary numbers:>> E = {'a11111000100z', 'a101z', 'a000000000011000z', 'a1111z'};>> sort(E) % for comparison.ans = 'a000000000011000z' 'a101z' 'a11111000100z' 'a1111z'>> natsort(E, '[01]+', '%b')ans = 'a101z' 'a1111z' 'a000000000011000z' 'a11111000100z'%% Case sensitivity:>> F = {'a2', 'A20', 'A1', 'a10', 'A2', 'a1'};>> natsort(F, [], 'ignorecase') % defaultans = 'A1' 'a1' 'a2' 'A2' 'a10' 'A20'>> natsort(F, [], 'matchcase')ans = 'A1' 'A2' 'A20' 'a1' 'a2' 'a10'%% Sort order:>> G = {'2', 'a', '', '3', 'B', '1'};>> natsort(G, [], 'ascend') % defaultans = '' '1' '2' '3' 'a' 'B'>> natsort(G, [], 'descend')ans = 'B' 'a' '3' '2' '1' ''>> natsort(G, [], 'num> natsort(G, [], 'char> natsort({'a18446744073709551615z', 'a18446744073709551614z'}, [], '%lu')ans = 'a18446744073709551614z' 'a18446744073709551615z'

On average the surface area A of human beings is related to weight W and height H. Measurements on a number of individuals of height 180 cm and diffirerent weights (kg) give values of A (m2)in the following table: It was found that a power law A=a*W^b fits these data reasonably well. Evaluate the constants a, and b and predict what the surface area is for between 70-90 kg person. W=[70 75 77 80 82 84 87 90];A=[2.1 2.12 2.15 2.2 2.22 2.23 2.26 2.3];%A=a*W^b;logW=log(W);logA=log(A);p=polyfit(logW,logA,1);weight=70:90;area=exp(polyval(p,log(weight)));plot(W,A,'ro',weight,area,'b-');

On average the surface area A of human beings is related to weight W and height H. Measurements on a number of individuals of height 180 cm and diffirerent weights (kg) give values of A (m2)in the following table: It was found that a power law A=a*W^b fits these data reasonably well. Evaluate the constants a, and b and predict what the surface area is for a 95 kg person. W=[70 75 77 80 82 84 87 90];A=[2.1 2.12 2.15 2.2 2.22 2.23 2.26 2.3];%A=a*W^b;logW=log(W);logA=log(A);p=polyfit(logW,logA,1);weight=95;area=exp(polyval(p,log(weight)));fprintf('for %d kgs for the surface are is: %f\n',weight,area);

FRESNEL(X) calculates the values of the Fresnel integrals for real values of vector X, i.e. C = \int_0^x cos(pi*t^2/2) dt, (0a) S = \int_0^x sin(pi*t^2/2) dt (0b)Also, it evaluates the following variations of the Fresnel integrals C1 = \sqrt(2/pi) \int_0^x cos(t^2) dt, (1a) S1 = \sqrt(2/pi) \int_0^x sin(t^2) dt (1b) and C2 = \sqrt(1/2/pi) \int_0^x cos(t) / \sqrt(t) dt, (2a) S2 = \sqrt(1/2/pi) \int_0^x sin(t) / \sqrt(t) dt (2b)The integrals are calculated as follows:- Values of X in the interval [-5,5] are looked up in Table 7.7 in [1] and interpolated ('cubic'), if necessary. This table has values of the Fresnel integrals with 7 significant digits and even linear interpolation gives an error of no more than 3e-004. - Values outside the interval [-5,5] are evaluated using the approximations under Table 7.7 in [1]. The error is less than3e-007. NOTE: The Tables were OCR'ed and although thoroughly checked, there might be some mistakes. Please let me know if you find any.REFERENCE[1] Abramowitz, M. and Stegun, I. A. (Eds.). "Error Function and Fresnel Integrals." Ch. 7 in "Handbook of mathematical functions with formulas, Graphs, and mathematical tables", 9th printing. New York: Dover, pp. 295-329, 1970. EXAMPLES OF USAGE>> Y = fresnel(X,'c');returns the Fresnel C integral according to eq. (0a)>> Y = fresnel(X,'s',2);returns the Fresnel S integral values according to eq. (2b)>> [C,S] = fresnel(X,[],1)returns the both the Fresnel C and S integral values according to eqs. (1a), (1b)>> [C,S] = fresnel(X,[])returns the both the Fresnel C and S integral values according to eqs. (0a), (0b)

MATLAB routines for computation of Special FunctionsThese routines are a direct translation, performed using f2matlab, of the original FORTRAN-77 implementation of "Computation of Special Functions."For detailed description of the algorithm of each program, please consult the book "Computation of Special Functions."Also see Errata at:http://ceta.mit.edu/comp_spec_func/Bernoulli numbersEuler numbersChebyshev, Laguerre, and Hermite polynomialsGauss-Legendre quadratureGauss-LaguerreGauss-Hermitegamma function.logarithm of the gamma function.gamma function with a complex argument.beta function.psi function.psi function with a complex argument.incomplete gamma function.incomplete beta function.Legendre polynomialsLegendre functions of the second kindassociated Legendre polynomialsBessel functions of the first and second kindszeros of the Bessel functions of the first and second kindslambda functionsmodified Bessel functions of the first and second kindsHankel functions of the first and second kindsintegral of Bessel functions J0(t) and Y0(t) from 0 to xintegral of [1-J0(t)]/t from 0 to x and Y0(t)/t from x to infinityintegral of modified Bessel functions I0(t) and K0(t) from 0 to xintegral of [1-I0(t)]/t from 0 to x and K0(t) from x to infinityspherical Bessel functions of the first and second kindsRiccati-Bessel functions of the first kind and second kindmodified spherical Bessel functions of the first kind and second kindKelvin functionszeros of the Kelvin functionsAiry functionsintegral of the Airy functions.zeros of Airy functionsStruve functions with an arbitrary orderintegral of Struve function H0(t) from 0 to x.integral of H0(t)/t from x to infinity.modified Struve function with an arbitrary order.integral of modified Struve function L0(t) from 0 to x.hypergeometric functionhypergeometric function M(a,b,z)hypergeometric function U(a,b,x)parabolic cylinder functions Dv(z)parabolic cylinder functions Vv(x)parabolic cylinder functions W(a,+/-x)characteristic values for the Mathieu and modified Mathieu functions.expansion coefficients for the Mathieu and modified Mathieu functions.Mathieu functionsmodified Mathieu functions of the first and second kindscharacteristic values for spheroidal wave functions.angular spheroidal wave functionsradial spheroidal wave functionserror function.Fresnel Integrals.modified Fresnel integrals.complex zeros of the error function.complex zeros of the Fresnel Integrals.cosine and sine integralscomplete and incomplete elliptic integrals of the first and second kinds.complete and incomplete elliptic integrals of the third kind.Jacobian elliptic functions.exponential integral E1(x)exponential integrals En(x)exponential integral Ei(x)

This is a demo for the metaheuristic algorithm, Novel Bat Algorithm (NBA). Different from the basic Bat Algorithm (BA), the different individuals in NBA have different search strategies, and a self-adaptive local search strategy is also embedded into NBA. In this sense, NBA is a multi-swarm and self-adaptive algorithm. Simulations and comparisons show NBA’s superiority over many metaheuristic algorithms.

Syntax:hFig = uiinspect(obj) Description:UIINSPECT inspects an object handle (e.g., Java, COM, Handle Graphics, Matlab class, Dot-Net etc.) and displays the inspection results in a unified Matlab window. UIINSPECT displays a unified window with all relevant object methods (as can be displayed via Matlab's methodsview function), properties (as can be displayed via Matlab's inspect function), static fields, and callbacks. UIINSPECT also displays properties and fields that are not normally displayed with Matlab's inspect function. Property meta-data such as type, accessibility, visibility and default value are also displayed. Unlike Matlab's inspect function, multiple UIINSPECT windows can be opened simultaneously. Object properties and callbacks may be modified interactively within the UIINSPECT window. hFig = UIINSPECT returns a handle to the created figure window. UIINSPECT opens a regular Matlab figure window which may be accessed via hFig (unlike Matlab's methodsview function which opens a Java frame that is not easily accessible from Matlab). Examples: hFig = uiinspect(0); % Matlab root (desktop) handle hFig = uiinspect(handle(0)); hFig = uiinspect(gcf); % Figure handle hFig = uiinspect(handle(gcf)); uiinspect(get(gcf,'JavaFrame')); uiinspect(classhandle(handle(gcf))); % UDD handle uiinspect(findprop(handle(gcf),'MenuBar')); % Meta-data handle uiinspect('java.lang.String'); % Java class name uiinspect(java.lang.String('yes')); % Java class object reference uiinspect(actxserver('Excel.Application')); % COM/ActiveX object uiinspect(Employee) % Matlab class object uiinspect(?handle) % Matlab metaclass object uiinspect('meta.class') % Matlab class name uiinspect(System.Diagnostics.Process.GetCurrentProcess) % Dot-Net object Warning:This code heavily relies on undocumented and unsupported Matlab functionality. It works on Matlab 7.1 and later releases, but use at your own risk!Technical explanation and details:http://undocumentedmatlab.com/blog/uiinspectBugs and suggestions:Please send to Yair Altman (altmany at gmail dot com)

Rigorous coupled wave analysis (RCWA) based on the scattering matrix (SM) algorithm is one of the most powerful tools for the electromagnetic simulation of patterned multilayer structures. PPML - RCWA is a project which implements the SM-RCWA, based on the formalisms of [a-d]. Three groups of functions are available: one is for 1-d patterns under TM polarization, another is for 1-d anisotropic (biaxial) patterns, the third for certain 2-d patterns.For 1-d TM patterns, currently available are functions for the calculation ofi) intensity reflectance, transmittance, and layer-by-layer absorbance ii) the full 2x2 scattering matrix iii) the E and S fields inside the structureThe proper factorization rules [c,d] make the code extremely performing, and fully suitable for the simulation of metal components (plasmonic gratings).Out-of-plane uniaxial materials can be treated.For 1-d biaxial media, the following function is available:i) amplitude, phase and polarization of transmitted diffracted wavesFor 2-d patterns, currently available are functions for the calculation ofi) zero-diffraction order scattering matrix (i.e, the 4x4 matrix whose submatrices are the transmission and reflection Jones matrices.)Allowed unit cell geometries are rectangular and L-shaped inclusions (see the Manual for details). The proper factorization rules are implemented [c,d], thus allowing for a fast convergence even in presence of metallic inclusions.Conducting interfaces can be seamlessly included in all the geometries by specifying their in-plane conductivity.The present code is distributed for free, but we kindly ask you to cite its source and, if applies, the publications below.Several publications are based on PPML (see below). For some of them, you can find the corresponding tutorial in the software package.----------------------------------------------------------Publications based on PPML (not exhaustive list)S. Zanotto, ... A. Pitanti, "Photonic bands, superchirality, and inverse design of a chiral minimal metasurface", Nanophotonics (2019), DOI: 10.1515/nanoph-2019-0321 S. Zanotto, ... A. Pitanti, "Optomechanics of Chiral Dielectric Metasurfaces", Advanced Optical Materials (2020), DOI: 10.1002/adom.201901507S. Zanotto, ... D. S. Wiersma, "Multichannel remote polarization control enabled by nanostructured Liquid Crystalline Networks", Applied Physics Letters (2019), DOI 10.1063/1.5096648S. Zanotto, G. C. La Rocca, and A. Tredicucci, “Understanding and overcoming fundamental limits of asymmetric light-light switches”, Optics Express 26, 3, 3618 (2018).S. Zanotto, ..., A. Melloni, "Metasurface reconfiguration through lithium ion intercalation in a transition metal oxide", Advanced Optical Materials 2017, 5, 1600732 (2017).S. Zanotto and A. Tredicucci, "Universal lineshapes at the crossover between weak and strong critical coupling in Fano-resonant coupled oscillators", Scientific Reports 6, 24592 (2016).L. Baldacci, ..., A. Tredicucci, “Interferometric control of absorption in thin plasmonic metamaterials: general two port theory and broadband operation”, Optics Express 23, 9202 (2015).S. Zanotto, ... A. Tredicucci, “Perfect energy feeding into strongly coupled systems and interferometric control of polariton absorption”, Nature Physics 10, 830 (2014).J.-M. Manceau, ..., R. Colombelli, “Mid-infrared intersubband polaritons in dispersive metal-insulator-metal resonators”, Appl. Phys. Lett. 105, 081105 (2014).J.-M. Manceau, ..., R. Colombelli, “Optical critical coupling into highly confining metal-insulator-metal resonators”, Appl. Phys. Lett. 103, 091110 (2013).S. Zanotto, ..., A. Tredicucci, “Ultrafast optical bleaching of intersubband cavity polaritons”, Phys. Rev. B 86, 201302(R) (2012).S. Zanotto, ... A. Tredicucci, “Analysis of line shapes and strong coupling with intersubband transitions in one-dimensional metallodielectric photonic crystal slabs”, Phys. Rev. B 85, 035307 (2012).R. Degl'Innocenti, ... A. Tredicucci, “One-dimensional surface-plasmon gratings for the excitation of intersubband polaritons in suspended membranes”, Solid State Comm. 151, 1725-1727 (2011).S. Zanotto, ... A. Tredicucci, “Intersubband polaritons in a one-dimensional surface plasmon photonic crystal”, Appl. Phys. Lett. 97, 231123 (2010).References for the methoda. D. M. Whittaker & I. S. Culshaw, "Scattering-matrix treatment of patterned multilayer photonic structures",Phys. Rev. B 60, 2610 (1999).b.M. Liscidini, D. Gerace, L. C. Andreani & J. E. Sipe, "Scattering-matrix analysis of periodically patterned multilayers with asymmetric unit cells and birefringent media", Phys. Rev. B 77, 035324 (2008).c. L. Li. "Use of Fourier series in the analysis of discontinuous periodic structures". J. Opt. Soc. Am. A 13, 1870 (1996)d.Lalanne, Philippe, and G. Michael Morris, "Highly improved convergence of the coupled-wave method for TM polarization", JOSA A 13, 779 (1996).

The Mixing Oceanographic Toolbox provides a framework to estimate the dissipation rate and diffusivity from Electromagnetic Autonomous Profiling Explorer (EM-APEX) float observational data. The EM-APEX floats measure the temperature, salinity, pressure, and horizontal velocity of the current. Vertical gradients of velocity and buoyancy are estimated and a finescale parameterization is applied. This method provides order of magnitude estimates of mixing as well as estimates of the regional variability of mixing..All information in MX_library_report.pdf.Citation: Meyer, Amelie, H. E. Phillips, B. M. Sloyan, and K. L. Polzin: Mixing (MX) Oceanographic Toolbox for EM-APEX* float data applying shear-strain finescale parameterization, 69pp, Institute for Marine and Antarctic Studies, University of Tasmania, Hobart, Technical Report, August 2014, DOI:10.4226/77/58acefb4cdb29.

Syntax:[h1,h2,hDivider] = uisplitpane(hParent,'propName',propVal,...) Description:UISPLITPANE splits the specified container(s) (figure, panel or frame, referenced by handle(s) hParent) into two distinct panes (panels) separated by a movable divider. If no hParent container is specified, then the current figure (gcf) is assumed. Matlab components may freely be added to each of the panes. Pane sizes may be modified by dragging or programmatically repositioning the movable divider.UISPLITPANE returns the handles to the left/bottom sub-container h1, right/top sub-container h2, and the split-pane divider hDivider. If a vector of several hParents was specified, then h1,h2 & hDivider will be corresponding vectors in the containing hParents. If the hParents are found to be non-unique, then the returned handles will correspond to the unique sorted vector of hParents, so that no hParent will be split more than once. The UISPLITPANE divider can be dragged to either side, up to the specified DividerMinLocation to DividerMaxLocation property values (defaults: 0.1 and 0.9 respectively, meaning between 10-90% of range). In Matlab 7+, additional one-click buttons are added to the divider, which enable easy flushing of the divider to either side, regardless of DividerMinLocation & DividerMaxLocation property values. Several case-insensitive properties may be specified as P-V pairs: - 'Orientation': 'horizontal' (default) or 'vertical' - 'Parent': Handle(s) of containing figure/panel/frame - 'DividerWidth': Divider width (1-25 [pixels], default=5) - 'DividerColor': Divider color (default=figure background color) - 'DividerLocation': Divider normalized initial location (.001-.999, default=0.5) - 'DividerMinLocation': Normalized minimal left/bottom pane size (0-1, default=0.1) - 'DividerMaxLocation': Normalized maximal left/bottom pane size (0-1, default=0.9) hDivider is a standard Matlab object handle possessing all these additional properties. All these properties are gettable/settable via the hDivider handle, except for the 'Orientation' & 'Parent' properties which become read-only after the UISPLITPANE is constructed. hDivider also exposes the following read-only properties: - 'LeftOrBottomPaneHandle': h1 value returned by this function - 'RightOrTopPaneHandle': h2 value returned by this function - 'DividerHandle': the HG container handle (a numeric value) - 'JavaComponent': handle to the underlying java divider obj - 'ContainerParentHandle': handle to hParent container Note: this is important in Matlab 6 which does ^^^^ not allow hierarchical UI containers - 'ContainerParentVarName': hParent variable name if available Example:[hDown,hUp,hDiv1]=uisplitpane(gcf,'Orientation','ver','dividercolor',[0,1,0]);[hLeft,hRight,hDiv2]=uisplitpane(hDown,'dividercolor','r','dividerwidth',3);t=0:.1:10; hax1=axes('Parent',hUp); plot(t,sin(t));hax2=axes('parent',hLeft); plot(t,cos(t));hax3=axes('parent',hRight); plot(t,tan(t));hDiv1.DividerLocation = 0.75; % one way to modify divider...set(hDiv2,'DividerColor','red'); % ...and this is another way... Technical description:http://UndocumentedMatlab.com/blog/uisplitpaneBugs and suggestions:Please send to Yair Altman (altmany at gmail dot com) Warning:This code heavily relies on undocumented and unsupported Matlab functionality. It works on Matlab 6+, but use at your own risk!

This function scans the Windows registry in two places and associates active COM ports with their registered "Friendly Name". The function returns an N x 2 cell array where N is the number of active COM ports. The first column contains the friendly names of the devices where they exist and the second contains their COM number. If no devices with friendly names are found, devices is empty.:This function is not necessarily optimized but it is my solution to identifying serial devices connected by virtual COM port in Windows without having to query every device. If multiple devices with the same friendly name are connected to the computer, the output will contain both devices with their COM ports but they will be otherwise indistinguishable by this function.

The model presents Battery charging/discharging Control implemented in a case study that involves a DC bus (with a constant voltage), battery, a common load, and a bidirectional two-switch Buck-Boost DC-DC converter.The control of battery charging and discharging is based on two PI controllers:1- one is for reference current generation (dependant on mode of operation: charging or discharging)2- the other is for Current control of battery.The presented case study includes two modes of operation:1-Charging mode: automatically activated when DC bus is connected and the control objective i.e: set point (of the 1st PI closed loop) becomes the full voltage of battery.2-Discharding mode: automatically activated when DC bus is NOT connected and the control objective (of the 1st PI closed loop) becomes load voltage in order the maintain a constant load voltage during discharging.The following video (which you can check for more details) inspired me to develop this model:https://www.youtube.com/watch?v=203f1eGLq9E&t=4sThanksOsama M. Hebalaemail: ohibala@aast.edu

JSONLab: compact, portable, robust JSON/binary-JSON encoder/decoder for MATLAB/OctaveWe strongly encourage all users help us fill out a brief community survey to help developers better integrate JSONLab with our JSON-based scientific data resources at https://neurojson.io, registered users can receive future critical updatesv2.9.8Copyright (c) 2011-2024 Qianqian Fang License: BSD or GNU General Public License version 3 (GPL v3), see License*.txtVersion: 2.9.8 (Micronus Prime - Beta)URL: https://neurojson.org/jsonlabUser forum: https://github.com/orgs/NeuroJSON/discussions/Compatibility: MATLAB R2008 or newer, GNU Octave 3.8 or newerAcknowledgement: This project is supported by US National Instituteof Health (NIH) grant U24-NS124027Compatible SpecificationsJData Specification Version: V1 Draft-3Binary JData Specification Version: V1 Draft-2JSON-Mmap Specification Version: V1 Draft-1What's NewWe are excited to announce that the JSONLab project, as the official reference library for both JData and BJData specifications, has been funded by the US National Institute of Health (NIH) as part of the NeuroJSON project (https://neurojson.org and https://neurojson.io).The goal of the NeuroJSON project is to develop scalable, searchable, and reusable neuroimaging data formats and data sharing platforms. All data produced from the NeuroJSON project will be using JSON/Binary JData formats as the underlying serialization standards and the lightweight JData specification as language-independent data annotation standard, all of which have been evolved from the over a decade development of JSONLab.JSONLab v2.9.8 - code named "Micronus Prime - beta" - is the beta-release of the next milestone (v3.0), containing a number of key feature enhancements and bug fixes. The major new features includeexporting JSON Memory-Map (jsonget,jsonset) for rapid disk-map like reading/writing of JSON/binary JSON files and writing, implementing JSON-Mmap spec v1 Draft 1supporting JSONPath query (jsonpath) to MATLAB data and JSON/binary JSON file and streams, including deep-scan operators,(breaking) upgrading the supported BJData spec to V1 Draft 2 where the default numerical data byte order changed from Big-Endian to Little-Endian,adding initial support to JData _DataLink_ decoding to link multiple JSON/binary JSON filesdynamically cache linked data files (jsoncache, jdlink) to permit on-demand download and processing of complex JSON-encoded datasets such as neuroimaging datasets hosted on https://neurojson.iosupport high-performance Blosc2 meta-compressor for storing large N-D array data,savejson/loadjson can use MATLAB/Octave built-in jsonencode/jsondecode using the BuiltinJSON optionautomatically switch from struct to containers.Map when encoded key-length exceeds 63provide fall-back zlib/gzip compression/decompression function (octavezmat) on Octave when ZMat is not installedinclude built-in .nii/.nii.gz/.jnii/.h5/.snirf/.tsv/.csv parsers to allow loadjd.m to read wide range of filesinclude json2couch from jbids (https://github.com/NeuroJSON/jbids) to allow uploading json files to CouchDB serverThere have been many major updates added to this release since the previous release v2.0 in June 2020. A list of the major changes are summarized below (with key features marked by *), including the support to BJData Draft-2 specification, new interface functions savejd/loadjd, and options to use MATLAB/Octave built-in jsonencode/jsondecode functions. The octave-jsonlab package has also been included in the official distributions of Debian Bullseye and Ubuntu 21.04 or newer.2024-03-28 [b39c374] [feat] add json2couch from jbids toolbox2024-03-27*[2e43586] [feat] merge nii/jnii/hdf5/tsv reading functions self-contained2024-03-27 [b482c8f] [test] pass all tests on matlab R2010b2024-03-27 [2008934] [doc] additional documentations on decompression functions2024-03-27 [0a582fb] [doc] add documentations for jsonpath, jsoncache, jdlink, and maxlinklevel2024-03-27 [5dba1de] [bug] .. searches deep level of struct, make jdlink work for Octave 4.2 and 5.22024-03-27 [fea481e] [doc] add line-by-line comment on examples, add jsonset/jsonget2024-03-26 [e1d386d] [feat] support saving dictionary to json and bjdata2024-03-26 [dfc744b] [feat] support caching data from any URL using hash, add NO_ZMAT flag2024-03-24 [22d297e] [doc] fix README.rst formatting issues2024-03-24 [7e27db5] [doc] update documentation, preparing for v2.9.8 release2024-03-24 [1227a0b] [format] reformat2024-03-24 [67f30ca] [feat] support using . or [] in JSONPath to escape dots in key names2024-03-24 [ee830cd] [bug] fix error_pos error when giving a non-existant input file2024-03-24 [d69686d] [feat] add jdlink to dynamically download and cache linked data2024-03-22 [772a1ef] [ci] fix octave failed test2024-03-22*[cff529a] [test] add jsonpath test, refine jsonpath syntax support2024-03-22 [22435e4] [bug] fix jsonpath handling of recursive deep scans2024-03-21 [c9f8a20] [bug] support deep scan in cell and struct, merge struct/containers.Map2024-03-21 [394394a] [bug] improve jsonpath cell with deep scan2024-03-20 [a599e71] [feat] add jsoncache to handle _DataLink_ download cache, rename jsonpath2024-02-19*[4f2edeb] [feat] support .. jsonpath operator for deep scan2024-01-11 [c43a758] [bug] fix missing index_esc reset, add test for automap2024-01-11*[ef5b472] [feat] automatically switch to map object when key length > 632023-11-17 [ee24122] use sprintf to replace unescapejsonstring2023-11-12 [abe504f] [ci] test again on macos-122023-11-12 [d2ff26a] [ci] install octave via conda on macos to avoid hanged install2023-11-07 [33263de] completely reformat m-files using miss_hit2023-11-07 [3ff781f] make octavezmat work on matlab2023-10-29 [ea4a4fd] make test script run on MATLAB R2010b2023-10-27 [ca91e07] use older matlab due to matlab-actions/run-command#432023-10-27 [4bf8232] add NO_ZMAT flag, fix fread issue2023-10-27*[ce3c0a0] add fallback zlib/glib support on Octave via file-based zip/unzip2023-10-26 [7ab1b6e] fix error for expecting an ending object mark when count is given2023-09-08 [6dfa58e] Fix typos found by codespell2023-06-27 [7d7e7f7] fix typo of compression method2023-06-27*[c25dd0f] support blosc2 codecs in save and load data, upgrade jsave/jload2023-06-19 [b23181a] test root-level indentation...detailed update logs can be found at https://github.com/fangq/jsonlab/releases/tag/v2.9.8Please note that the savejson/loadjson in both JSONLab v2.0-v3.0 are compliant with JData Spec Draft 3; the savebj/loadbj in JSONLab v3.0 is compatible to BJData spec Draft 2, which contains breaking feature changes compared to those in JSONLab v2.0.The BJData spec was derived from UBJSON spec Draft 12, with the following breaking differences:BJData adds 4 new numeric data types: uint16 [u], uint32 [m], uint64 [M] and float16 [h] (supported in JSONLab v2.0 or newer)BJData supports an optimized ND array container (supported in JSONLab since 2013)BJData does not convert NaN/Inf/-Inf to null (supported in JSONLab since 2013)BJData Draft 2 changes the default byte order to Little-Endian instead of Big-Endian (JSONLab 3.0 or later)BJData only permits non-zero-fixed-length data types as the optimized array type, i.e. only UiuImlMLhdDC are allowedTo avoid using the new features, one should attach 'UBJSON',1 and 'Endian','B' in the savebj command assavebj('',data,'FileName','myfile.bjd','UBJSON',1, 'Endian','B');To read BJData data files generated by JSONLab v2.0, you should calldata=loadbj('my_old_data_file.bjd','Endian','B')You are strongly encouraged to convert all pre-v2.9 JSONLab generated BJD or .pmat files using the new format.IntroductionJSONLab is an open-source JSON/UBJSON/MessagePack encoder and decoder written completely in the native MATLAB language. It can be used to convert most MATLAB data structures (array, struct, cell, struct array, cell array, and objects) into JSON/UBJSON/MessagePack formatted strings and files, or to parse a JSON/UBJSON/MessagePack file into a MATLAB data structure. JSONLab supports both MATLAB and GNU Octave (a free MATLAB clone).Compared to other MATLAB/Octave JSON parsers, JSONLab is uniquely lightweight, ultra-portable, producing dependable outputs across a wide-range of MATLAB (tested on R2008) and Octave (tested on v3.8) versions. It also uniquely supports BinaryJData/UBJSON/MessagePack data files as binary-JSON-like formats, designed for efficiency and flexibility with loss-less binary storage. As a parser written completely with the native MATLAB language, it is surprisingly fast when reading small-to-moderate sized JSON files (1-2 MB) with simple hierarchical structures, and is heavily optimized for reading JSON files containing large N-D arrays (known as the "fast array parser" in loadjson).JSON (JavaScript Object Notation) is a highly portable, human-readable and "fat-free" text format to represent complex and hierarchical data, widely used for data-exchange in applications. UBJSON (Universal Binary JSON) is a binary JSON format, designed to specifically address the limitations of JSON, permitting the storage of binary data with strongly typed data records, resulting in smaller file sizes and fast encoding and decoding. MessagePack is another binary JSON-like data format widely used in data exchange in web/native applications. It is slightly more compact than UBJSON, but is not directly readable compared to UBJSON.We envision that both JSON and its binary counterparts will play important roles for storage, exchange and interoperation of large-scale scientific data among the wide-variety of tools. As container-formats, they offer both the flexibility and generality similar to other more sophisticated formats such as HDF5, but are significantlysimpler with a much greater software ecosystem.Towards this goal, we have developed the JData Specification (http://github.com/NeuroJSON/jdata) to standardize serializations of complex scientific data structures, such as N-D arrays, sparse/complex-valued arrays, trees, maps, tables and graphs using JSON/binary JSON constructs. The text and binary formatted JData files are syntactically compatible with JSON/UBJSON formats, and can be readily parsed using existing JSON and UBJSON parsers. JSONLab is not just a parser and writer of JSON/UBJSON data files, but one that systematically converts complex scientific data structures into human-readable and universally supported JSON forms using the standardized JData data annotations.InstallationThe installation of JSONLab is no different from installing any other MATLAB toolbox. You only need to download/unzip the JSONLab package to a folder, and add the folder's path to MATLAB/Octave's path list by using the following command:addpath('/path/to/jsonlab');If you want to add this path permanently, you can type pathtool, browse to the JSONLab root folder and add to the list, then click "Save". Then, run rehash in MATLAB, and type which savejson, if you see an output, that means JSONLab is installed for MATLAB/Octave.If you use MATLAB in a shared environment such as a Linux server, the best way to add path is to typemkdir ~/matlab/nano ~/matlab/startup.mand type addpath('/path/to/jsonlab') in this file, save and quit the editor. MATLAB will execute this file every time it starts. For Octave, the file you need to edit is ~/.octaverc, where ~ is your home directory.To use the data compression features, please download the ZMat toolbox from https://github.com/NeuroJSON/zmat/releases/latest and follow the instruction to install ZMat first. The ZMat toolbox is required when compression is used on MATLAB running in the -nojvm mode or GNU Octave, or 'lzma/lzip/lz4/lz4hc' compression methods are specified. ZMat can also compress large arrays that MATLAB's Java-based compression API does not support.Install JSONLab on Fedora 24 or laterJSONLab has been available as an official Fedora package since 2015. You may install it directly using the below commandsudo dnf install octave-jsonlabTo enable data compression/decompression, you need to install octave-zmat usingsudo dnf install octave-zmatThen open Octave, and type pkg load jsonlab to enable jsonlab toolbox.Install JSONLab on DebianJSONLab is currently available on Debian Bullseye. To install, you may runsudo apt-get install octave-jsonlabOne can alternatively install matlab-jsonlab if MATLAB is available.Install JSONLab on UbuntuJSONLab is currently available on Ubuntu 21.04 or newer as package octave-jsonlab. To install, you may runsudo apt-get install octave-jsonlabFor older Ubuntu releases, one can add the below PPAhttps://launchpad.net/~fangq/+archive/ubuntu/ppaTo install, please runsudo add-apt-repository ppa:fangq/ppasudo apt-get updateto add this PPA, and then usesudo apt-get install octave-jsonlabto install the toolbox. octave-zmat will be automatically installed.Install JSONLab on Arch LinuxJSONLab is also available on Arch Linux. You may install it using the below commandsudo pikaur -S jsonlabUsing JSONLabJSONLab provides a pair of functions, loadjson -- a JSON parser, and savejson -- a MATLAB-to-JSON encoder, to read/write the text-based JSON; it also provides three equivalent pairs -- loadbj/savebj for binary JData, loadubjson/saveubjson for UBJSON and loadmsgpack/savemsgpack for MessagePack. The load* functions for the 3 supported data formats share almost the same input parameter format, similarly for the 3 save* functions (savejson/saveubjson/savemsgpack). These encoders and decoders are capable of processing/sharing almost all data structures supported by MATLAB, thanks to jdataencode/jdatadecode - a pair of in-memory data converters translating complex MATLAB data structures to their easy-to-serialized forms according to the JData specifications. The detailed help information can be found in the Contents.m file.In JSONLab 2.9.8 and later versions, a unified file loading and saving interface is provided for JSON, binary JSON and HDF5, including loadjd and savejd for reading and writing below files types:JSON based files: .json, .jdt (text JData file), .jmsh (text JMesh file), .jnii (text JNIfTI file), .jnirs (text JSNIRF file)BJData based files: .bjd, .jdb (binary JData file), .bmsh (binary JMesh file), .bnii (binary JNIfTI file), .bnirs (binary JSNIRF file), .pmat (MATLAB session file)UBJSON based files: .ubjMessagePack based files: .msgpackHDF5 based files: .h5, .hdf5, .snirf (SNIRF fNIRS data files) - require EasyH5 toolboxIn the below section, we provide a few examples on how to us each of the core functions for encoding/decoding JSON/Binary JSON/MessagePack data.savejson.mjsonmesh=struct('MeshNode',[0 0 0;1 0 0;0 1 0;1 1 0;0 0 1;1 0 1;0 1 1;1 1 1],... 'MeshElem',[1 2 4 8;1 3 4 8;1 2 6 8;1 5 6 8;1 5 7 8;1 3 7 8],... 'MeshSurf',[1 2 4;1 2 6;1 3 4;1 3 7;1 5 6;1 5 7;... 2 8 4;2 8 6;3 8 4;3 8 7;5 8 6;5 8 7],... 'MeshCreator','FangQ','MeshTitle','T6 Cube',... 'SpecialData',[nan, inf, -inf]);% convert any matlab variables to JSON (variable name is used as the root name)savejson(jsonmesh)% convert matlab variables to JSON with a root-name "jmesh"savejson('jmesh',jsonmesh)% an empty root-name directly embed the data in the root {}% the compact=1 flag prints JSON without white-space in a single-linesavejson('',jsonmesh,'Compact',1)% if 3 inputs are given, the 3rd parameter defines the output file namesavejson('jmesh',jsonmesh,'outputfile.json')% param/value pairs can be provided after the 2nd input to customize outputs% if you want to use params/values and save JSON to a file, you must use the 'filename' to set output filesavejson('',jsonmesh,'FileName','outputfile2.json','ArrayIndent',0,'FloatFormat','\t%.5g')% jsonlab utilizes JData annotations to encode complex/sparse ND-arrayssavejson('cpxrand',eye(5)+1i*magic(5))% when setting 'BuiltinJSON' to 1, savejson calls jsonencode.m in MATLAB (R2016+)% or Octave (v7+) to convert data to JSON; this is typically faster, but does not% support all features native savejson offerssavejson('cpxrand',eye(5)+1i*magic(5), 'BuiltinJSON', 1)% JData annotations also allows one to compress binary strongly-typed data and store in the JSON% gzip/zlib are natively supported in MATLAB and Octave; using ZMat toolbox, one can use lz4, lzma, blosc2 etc compressorssavejson('ziparray',eye(10),'Compression','zlib','CompressArraySize',1)% 'ArrayToStruct' flag forces all arrays to use the JData ND array annotations to preserve typessavejson('',jsonmesh,'ArrayToStruct',1)% JData supports compact storage of special matrices using the '_ArrayShape_' annotationsavejson('',eye(10),'UseArrayShape',1)loadjson.m% loadjson can directly parse a JSON string if it starts with "[" or "{", here is an empty objectloadjson('{}')% loadjson can also parse complex JSON objects in a string formdat=loadjson('{"obj":{"string":"value","array":[1,2,3]}}')% if the input is a file name, loadjson reads the file and parse the data insidedat=loadjson(['examples' filesep 'example1.json'])% param/value pairs can be used following the 1st input to customize the parsing behaviordat=loadjson(['examples' filesep 'example1.json'],'SimplifyCell',0)% if a URL is provided, loadjson reads JSON data from the URL and return the parsed results,% similar to webread, except loadjson calls jdatadecode to decode JData annotationsdat=loadjson('https://raw.githubusercontent.com/fangq/jsonlab/master/examples/example1.json')% using the 'BuildinJSON' flag, one can use the built-in jsondecode.m in MATLAB (R2016+)% or Octave (7.0+) to parse the JSON data for better speed, note that jsondecode encode% key names differently compared to loadjsondat=loadjson('{"_obj":{"string":"value","array":[1,2,3]}}', 'builtinjson', 1)% when the JSON data contains long key names, one can use 'UseMap' flag to% request loadjson to store the data in a containers.Map instead of struct (key name limited to 63)dat=loadjson('{"obj":{"an object with a key longer than 63":"value","array":[1,2,3]}}', 'UseMap', 1)% loadjson can further download the linked data pointed by `_DataLink_` tag, and merge with the parentdat=loadjson('{"obj":{"_DataLink_":"https://raw.githubusercontent.com/fangq/jsonlab/master/examples/example1.json"},"array":[1,2]}','maxlinklevel',1)% a JSONPath can be attached to the URL to retrieve a sub elementdat=loadjson('{"obj":{"_DataLink_":"https://raw.githubusercontent.com/fangq/jsonlab/master/examples/example1.json:$.address.city"},"array":[1,2]}','maxlinklevel',1)% loadjson can optionally return a JSON-memory-map object, which defines each JSON element's% memory buffer offset and length to enable disk-map like fast read/write operations[dat, mmap]=loadjson('{"obj":{"key":"value","array":[1,2,3]}}')% if set 'mmaponly' to 1, loadjson only returns the JSON-mmap structuremmap=loadjson('{"obj":{"key":"value","array":[1,2,3]}}', 'mmaponly', 1)savebj.m% savebj works almost exactly like savejson, except that the output is the more compact binary JSONa={single(rand(2)), struct('va',1,'vb','string'), 1+2i};savebj(a)% customizing the root-name using the 1st input, and the 3rd input setting the output filesavebj('rootname',a,'testdata.ubj')% enabling the 'debug' flag to allow printing binary JSON in text-form, helping users to run tests or troubleshootsavebj('rootname',a, 'debug',1)% like savejson, savebj also allow data compression for even more compact storagesavebj('zeros',zeros(100),'Compression','gzip')% binary JSON does not need base64-encoding, therefore, the output can be ~33% smaller than text-based JSON[length(savebj('magic',magic(100),'Compression','zlib')), length(savejson('magic',magic(100),'Compression','zlib'))]% savebj can output other popular binary JSON formats, such as MessagePack or UBJSONsavebj('mesh',a,'FileName','meshdata.msgpk','MessagePack',1) % same as calling savemsgpacksavebj('mesh',a,'FileName','meshdata.ubj','UBJSON',1) % same as calling saveubjsonloadbj.m% similarly, loadbj does almost exactly the same as loadjson, but it parses binary JSON insteadobj=struct('string','value','array',single([1 2 3]),'empty',[],'magic',uint8(magic(5)));ubjdata=savebj('obj',obj);% loadbj can load a binary JSON (BJData - a derived format from UBJSON) object from a bufferdat=loadbj(ubjdata)% you can test if loadbj parsed object still matches the data saved using savebjclass(dat.obj.array)isequaln(obj,dat.obj)% similarly, savebj/loadbj can compress/decompress binary array data using various compressorsdat=loadbj(savebj('',eye(10),'Compression','zlib','CompressArraySize',1))% if given a path to a binary JSON file (.jdb,.bnii,.pmat,.jmsh,...), it opens and parses the filedat=loadbj('/path/to/a/binary_json.jdb');% loadbj can directly load binary JSON data files from URL, here is a binary-JSON based NIfTI filedat=loadbj('https://neurojson.org/io/stat.cgi?action=get&db=abide&doc=CMU_b&file=0a429cb9101b733f594eefc1261d6985-zlib.bnii')% similar to loadjson, loadbj can also return JSON-memory-map to permit disk-map% like direct reading/writing of specific data elements[dat, mmap]=loadbj(ubjdata)mmap=loadbj(ubjdata, 'mmaponly', 1)jdataencode.m% jdataencode transforms complex MATLAB data structures (ND-array, sparse array, complex arrays,% table, graph, containers.Map etc) into JSON-serializable forms using portable JData annotations% here, we show how to save a complex-valued sparse array using JSON JData annotationstestdata = struct('a',rand(5)+1i*rand(5),'b',[],'c',sparse(5,5));jd=jdataencode(testdata)savejson('',jd)% when setting 'annotatearray' to 1, jdataencode uses _ArrayType_/_ArraySize_/_ArrayData_% JData tags to store ND array to preserve data types; use 'prefix' to customize variable name prefixencodedmat=jdataencode(single(magic(5)),'annotatearray',1,'prefix','x')% when setting 'usearrayshape' to 1, jdataencode can use _ArrayShape_ to encode special matricesencodedtoeplitz=jdataencode(uint8(toeplitz([1,2,3,4],[1,5,6])),'usearrayshape',1)jdatadecode.m% jdatadecode does the opposite to jdataencode, it recognizes JData annotations and convert% those back to MATLAB native data structures, such as ND-arrays, tables, graph etcrawdata=struct('a',rand(5)+1i*rand(5),'b',[],'c',sparse(5,5));jd=jdataencode(rawdata)newjd=jdatadecode(jd)% we can test that the decoded data are the same as the originalisequaln(newjd,rawdata)% if one uses jsondecode to parse a JSON object, the output JData annotation name prefix is different% jsondecode adds "x_" as prefixrawdecode_builtin = jsondecode(savejson('',rawdata));rawdecode_builtin.afinaldecode=jdatadecode(rawdecode_builtin)% in comparison, loadjson calls encodevarname.m, producing "x0x5F_" as prefix (hex for '_')% encodevarname encoded names can be reversed to original decodevarname.mrawdecode_jsonlab = loadjson(savejson('',rawdata), 'jdatadecode', 0);rawdecode_jsonlab.afinaldecode=jdatadecode(rawdecode_jsonlab)savejd.m% savejd is a unified interface for savejson/savebj/savemsgpack/saveh5 depending on the output file suffixa={single(rand(2)), struct('va',1,'vb','string'), 1+2i};savejd('', a, 'test.json')savejd('', a, 'test.jdb')savejd('', a, 'test.ubj')savejd('', a, 'test.h5')loadjd.m% loadjd is a unified interface for loadjson/loadbj/loadmsgpack/loadh5/load/loadjnifti depending on the input file suffix% supported types include .json,.jnii,.jdt,.jmsh,.jnirs,.jbids,.bjd,.bnii,.jdb,.bmsh,.bnirs,.ubj,.msgpack,% .h5,.hdf5,.snirf,.pmat,.nwb,.nii,.nii.gz,.tsv,.tsv.gz,.csv,.csv.gz,.mat,.bvec,.bval; input can be an URLdata = loadjd('test.json');data = loadjd('test.jdb');data = loadjd('test.ubj');data = loadjd('test.h5');data = loadjd('file:///path/to/test.jnii');data = loadjd('https://neurojson.org/io/stat.cgi?action=get&db=abide&doc=CMU_b&file=0a429cb9101b733f594eefc1261d6985-zlib.bnii');jsonget.m% loadjson/loadbj JSON-memory-map (mmap) output returned by loadjson or loadbj% each mmap contains a pair of JSONPath and two numbers [offset, length] of the object in bytes in the buffer/filejsonstr = '{"obj":{"string":"value","array":[1,2,3]}}';mmap=loadjson(jsonstr, 'mmaponly', 1)% mmap = [ ["$",[1,42]], ["$.obj",[8,34]], ["$.obj.string",[18,7]], ["$.obj.array",[34,7]] ]% this means there are 4 objects, root '$', with its content starting byte 1, with a length of 42 bytes;% content of object '$.obj' starts byte 8, with a length of 34 bytesmmap{:}% using the above mmap, jsonget can return any raw data without needing to reparse jsonstr% below command returns '[1,2,3]' as a string by following the offset/length data in mmapjsonget(jsonstr, mmap, '$.obj.array')% you can request multiple objects by giving multiple JSONPath keysjsonget(jsonstr, mmap, '$.obj', '$.obj.string')% you can request multiple objects by giving multiple JSONPath keysjsonget(jsonstr, mmap, '$.obj', '$.obj.string')% jsonget not only can fast reading a JSON string buffer, it can also do disk-map read of a filemmap = loadjson('/path/to/data.json', 'mmaponly', 1);jsonget('/path/to/data.json', mmap, '$.obj')jsonset.m% using JSON mmap, one can rapidly modify the content of JSON object pointed by a pathjsonstr = '{"obj":{"string":"value","array":[1,2,3]}}';mmap=loadjson(jsonstr, 'mmaponly', 1)% we can rewrite object $.obj.array by changing its value '[1,2,3]' to a string "test"% this returns the updated jsonstr as '{"obj":{"string":"value","array":"test" }}'% the new value of a key must not have longer bytes than the original valuejsonset(jsonstr, mmap, '$.obj.array', '"test"')% one can change multiple JSON objects, below returns '{"obj":{"string":"new" ,"array":[] }}'jsonset(jsonstr, mmap, '$.obj.string', '"new"', '$.obj.array', '[]')% if mmap is parsed from a file, jsonset can perform disk-map like fast writing to modify the json contentmmap = loadjson('/path/to/data.json', 'mmaponly', 1);jsonset('/path/to/data.json', mmap, '$.obj.string', '"new"', '$.obj.array', '[]')jsonpath.m% JSONPath is a widely supported standard to index/search a large struct, such as those loaded from a JSON file% the jsonpath.m function implements a subset of the features% the below command returns the value of obj.key subfield, which is "value"obj = loadjson('{"obj":{"key":"value1","array":[1,2,3],"sub":{"key":"value2","array":[]}}}');jsonpath(obj, '$.obj.key')% using [] operator, one can also index array elements, index start from 0; the output below is 2jsonpath(obj, '$.obj.array[1]')% [] operator supports range, for example below commands yields [1,2]jsonpath(obj, '$.obj.array[0:1]')% a negative index in [] counting elements backwards, -1 means the last elementjsonpath(obj, '$.obj.array[-1]')% jsonpath.m supports JSONPath's deep-scan operator '..', it traverses through the struct% and find all keys following .., here the output is {"value1", "value2"}jsonpath(obj, '$.obj..key')% you can further concatenate JSONPath operators to select outputs from the earlier ones, this outputs {'value2'}jsonpath(obj, '$.obj..key[1]')% instead of .keyname, you can use [keyname], below command is the same as abovejsonpath(obj, '$[obj]..[key][1]')% one can escape special char, such as ".", in the key using special\.key or [special.key]jsonpath(obj, '$.obj.special\.key.sub')jsoncache.m% the _DataLink_ annotation in the JData specification permits linking of external data files% in a JSON file - to make downloading/parsing externally linked data files efficient, such as% processing large neuroimaging datasets hosted on http://neurojson.io, we have developed a system% to download files on-demand and cache those locally. jsoncache.m is responsible of searching% the local cache folders, if found the requested file, it returns the path to the local cache;% if not found, it returns a SHA-256 hash of the URL as the file name, and the possible cache folders%% When loading a file from URL, below is the order of cache file search paths, ranking in search order%% global-variable NEUROJSON_CACHE | if defined, this path will be searched first% [pwd '/.neurojson'] | on all OSes% /home/USERNAME/.neurojson | on all OSes (per-user)% /home/USERNAME/.cache/neurojson | if on Linux (per-user)% /var/cache/neurojson | if on Linux (system wide)% /home/USERNAME/Library/neurojson| if on MacOS (per-user)% /Library/neurojson | if on MacOS (system wide)% C:\ProgramData\neurojson | if on Windows (system wide)%% When saving a file from a URL, under the root cache folder, subfolders can be created;% if the URL is one of a standard NeuroJSON.io URLs as below%% https://neurojson.org/io/stat.cgi?action=get&db=DBNAME&doc=DOCNAME&file=sub-01/anat/datafile.nii.gz% https://neurojson.io:7777/DBNAME/DOCNAME% https://neurojson.io:7777/DBNAME/DOCNAME/datafile.suffix%% the file datafile.nii.gz will be downloaded to /home/USERNAME/.neurojson/io/DBNAME/DOCNAME/sub-01/anat/ folder% if a URL does not follow the neurojson.io format, the cache folder has the below form%% CACHEFOLDER{i}/domainname.com/XX/YY/XXYYZZZZ...%% where XXYYZZZZ.. is the SHA-256 hash of the full URL, XX is the first two digit, YY is the 3-4 digits% below command searches CACHEFOLDER{i}/io/openneuro/ds000001/sub-01/anat/, and return the path/filename[cachepath, filename] = jsoncache('https://neurojson.org/io/stat.cgi?action=get&db=openneuro&doc=ds000001&file=sub-01/anat/sub-01_inplaneT2.nii.gz&size=669578')% this searches CACHEFOLDER{i}/raw.githubusercontent.com/55/d2, and the filename is 55d24a4bad6ecc3f5dc4d333be728e01c26b696ef7bc5dd0861b7fa672a28e8e.json[cachepath, filename] = jsoncache('https://raw.githubusercontent.com/fangq/jsonlab/master/examples/example1.json')% this searches cachefolder{i}/io/adhd200/Brown folder, and look for file Brown.json[cachepath, filename] = jsoncache('https://neurojson.io:7777/adhd200/Brown')% this searches cachefolder{i}/io/openneuro/ds003805 folder, and look for file ds003805.json[cachepath, filename] = jsoncache('https://neurojson.io:7777/openneuro/ds003805')jdlink.m% jdlink dynamically downloads, caches and parses data files from one or multiple URLs% jdlink calls jsoncache to scan cache folders first, if a cache copy exists, it loads the cache first% here we download a dataset from NeuroJSON.io, containing many linked data filesdata = loadjson('https://neurojson.io:7777/openneuro/ds000001');% we now use jsonpath to scan all linked resources under subfolder "anat"alllinks = jsonpath(data, '$..anat.._DataLink_')% let's download all linked nifti files (total 4) for sub-01 and sub-02, and load the files as niidataniidata = jdlink(alllinks, 'regex', 'sub-0[12]_.*\.nii');% if you just want to download/cache all files and do not want to parse the files, you can runjdlink(alllinks);examplesUnder the examples folder, you can find several scripts to demonstrate the basic utilities of JSONLab. Running the demo_jsonlab_basic.m script, you will see the conversions from MATLAB data structure to JSON text and backward. In jsonlab_selftest.m, we load complex JSON files downloaded from the Internet and validate the loadjson/savejson functions for regression testing purposes. Similarly, a demo_ubjson_basic.m script is provided to test the saveubjson and loadubjson functions for various matlab data structures, and demo_msgpack_basic.m is for testing savemsgpack and loadmsgpack.Please run these examples and understand how JSONLab works before you use it to process your data.unit testingUnder the test folder, you can find a script to test individual data types and inputs using various encoders and decoders. This unit testing script also serves as a specification validator to the JSONLab functions and ensure that the outputs are compliant to the underlying specifications.In-memory data compression/decompressionJSONLab contains a set of functions to perform in-memory buffer data compression and decompressionData Compression: {zlib,gzip,base64,lzma,lzip,lz4,lz4hc,zstd,blosc2}encode.m% MATLAB running with jvm provides zlib and gzip compression natively% one can also install ZMat (https://github.com/NeuroJSON/zmat) to do zlib(.zip) or gzip (.gz) compressionoutput = zlibencode(diag([1,2,3,4]))[output, info] = zlibencode(uint8(magic(8)))outputbase64 = char(base64encode(output(:)))% char, numeric and logical ND-arrays are acceptable inputs to the compression functions[output, info] = gzipencode(uint8(magic(8)))% setting a negative integer between -1 to -9 to set compression level: -9 being the highest[output, info] = zlibencode(uint8(magic(8)), -9)% other advanced compressions are supported but requires ZMat% lzma offers the highest compression rate, but slow compresison speedoutput = lzmaencode(uint8(magic(8)))% lz4 offers the fastest compression speed, but slightly low compression ratiooutput = lz4encode(peaks(10))output = lz4hcencode(uint8(magic(8)))% zstd has a good balanced speed/ratio, similar to zliboutput = zstdencode(peaks(10))output = zstdencode(peaks(10), -9)Data Deompression: {zlib,gzip,base64,lzma,lzip,lz4,lz4hc,zstd,blosc2}decode.m% passing on a compressed byte-array buffer to *decode function decompresses the buffer[compressed, info] = zlibencode(eye(10));% the decompressed buffer is a byte-arraydecompressd = zlibdecode(compressed);% to fully recover the original data structure, one most use the info struct returned by the compressordecompressd = zlibdecode(compressed, info)% if one passes a zlib compressed buffer to a different decompressor, an error is reporteddecompressd = gzipdecode(compressed, info)outputbase64 = char(base64decode(base64encode('jsonlab test')))Using jsave/jload to share workspaceStarting from JSONLab v2.0, we provide a pair of functions, jsave/jload to store and retrieve variables from the current workspace, similar to the save/load functions in MATLAB and Octave. The files that jsave/jload reads/writes is by default a binary JData file with a suffix .pmat. The file size is comparable (can be smaller if use lzma compression) to .mat files. This feature is currently experimental.The main benefits of using .pmat file to share matlab variables includea .pmat file can be 50% smaller than a .mat file when using jsave(..., "compression","lzma"); the only drawback is longer saving time.a .pmat file can be readily read/opened among many programming environments, including Python, JavaScript, Go, Java etc, where .mat file support is not generally available. Parsers of .pmat files are largely compatible with BJData's parsers available at https://neurojson.org/#softwarea .pmat file is quasi-human-readable, one can see the internal data fields even in a command line, for example using strings -n 2 file.pmat | astyle, making the binary data easy to be understood, shared and reused.jsave/jload can also use MessagePack and JSON formats as the underlying data storage format, addressing needs from a diverse set of applications. MessagePack parsers are readily available at https://msgpack.org/jsave.mjsave % save the current workspace to default.pmatjsave mydata.pmatjsave('mydata.pmat','vars',{'var1','var2'})jsave('mydata.pmat','compression','lzma')jsave('mydata.json','compression','gzip')jload.mjload % load variables from default.pmat to the current workspacejload mydata.pmat % load variables from mydata.pmatvars=jload('mydata.pmat','vars',{'var1','var2'}) % return vars.var1, vars.var2jload('mydata.pmat','simplifycell',0)jload('mydata.json')Sharing JSONLab created data files in PythonDespite the use of portable data annotation defined by the JData Specification, the output JSON files created by JSONLab are 100% JSON compatible (with the exception that long strings may be broken into multiple lines for better readability). Therefore, JSONLab-created JSON files (.json, .jnii, .jnirs etc) can be readily read and written by nearly all existing JSON parsers, including the built-in json module parser in Python.However, we strongly recommend one to use a lightweight jdata module, developed by the same author, to perform the extra JData encoding and decoding and convert JSON data directly to convenient Python/Numpy data structures. The jdata module can also directly read/write UBJSON/Binary JData outputs from JSONLab (.bjd, .ubj, .bnii, .bnirs, .pmat etc). Using binary JData files are expected to produce much smaller file sizes and faster parsing, while maintaining excellent portability and generality.In short, to conveniently read/write data files created by JSONLab into Python, whether they are JSON based or binary JData/UBJSON based, one just need to download the below two light-weight python modules:jdata: PyPi: https://pypi.org/project/jdata/ ; Github: https://github.com/NeuroJSON/pyjdatabjdata PyPi: https://pypi.org/project/bjdata/ ; Github: https://github.com/NeuroJSON/pybjTo install these modules on Python 2.x, please first check if your system has pip and numpy, if not, please install it by running (using Ubuntu/Debian as example)sudo apt-get install python-pip python3-pip python-numpy python3-numpyAfter the installation is done, one can then install the jdata and bjdata modules bypip install jdata --userpip install bjdata --userTo install these modules for Python 3.x, please replace pip by pip3. If one prefers to install these modules globally for all users, simply execute the above commands usingsudo pip install jdatasudo pip install bjdataThe above modules require built-in Python modules json and NumPy (numpy).Once the necessary modules are installed, one can type python (or python3), and runimport jdata as jdimport numpy as npdata1=jd.loadt('myfile.json');data2=jd.loadb('myfile.bjd');data3=jd.loadb('myfile.pmat');where jd.loadt() function loads a text-based JSON file, performs JData decoding and converts the enclosed data into Python dict, list and numpy objects. Similarly, jd.loadb() function loads a binary JData/UBJSON file and performs similar conversions. One can directly call jd.load() to open JSONLab (and derived toolboxes such as jnifti: https://github.com/NeuroJSON/jnifti or jsnirf: https://github.com/NeuroJSON/jsnirf) generated files based on their respective file suffix.Similarly, the jd.savet(), jd.saveb() and jd.save functions can revert the direction and convert a Python/Numpy object into JData encoded data structure and store as text-, binary- and suffix-determined output files, respectively.Known Issues and TODOsJSONLab has several known limitations. We are striving to make it more general and robust. Hopefully in a few future releases, the limitations become less.Here are the known issues:3D or higher dimensional cell/struct-arrays will be converted to 2D arraysWhen processing names containing multi-byte characters, Octave and MATLAB can give different field-names; you can use feature('DefaultCharacterSet','latin1') in MATLAB to get consistentresultssavejson can only export the properties from MATLAB classes, but not the methodssaveubjson converts a logical array into a uint8 ([U]) arraya special N-D array format, as defined in the JData specification, is implemented in saveubjson. You may use saveubjson(...,'NestArray',1) to create UBJSON Draft-12 compliant filesloadubjson can not parse all UBJSON Specification (Draft 12) compliant files, however, it can parse all UBJSON files produced by saveubjson.Contribution and feedbackJSONLab is an open-source project. This means you can not only use it and modify it as you wish, but also you can contribute your changes back to JSONLab so that everyone else can enjoy the improvement. For anyone who want to contribute, please download JSONLab source code from its source code repositories by using the following command:git clone https://github.com/fangq/jsonlab.git jsonlabor browsing the github site athttps://github.com/fangq/jsonlabPlease report any bugs or issues to the below URL:https://github.com/fangq/jsonlab/issuesSometimes, you may find it is necessary to modify JSONLab to achieve your goals, or attempt to modify JSONLab functions to fix a bug that you have encountered. If you are happy with your changes and willing to share those changes to the upstream author, you are recommended to create a pull-request on github.To create a pull-request, you first need to "fork" jsonlab on Github by clicking on the "fork" button on top-right of JSONLab's github page. Once you forked jsonlab to your own directory, you should then implement the changes in your own fork. After thoroughly testing it and you are confident the modification is complete and effective, you can then click on the "New pull request" button, and on the left, select fangq/jsonlab as the "base". Then type in the description of the changes. You are responsible to format the code updates using the same convention (tab-width: 8, indentation: 4 spaces) as the upstream code.We appreciate any suggestions and feedbacks from you. Please use the following user forum to ask any question you may have regarding JSONLab:https://github.com/orgs/NeuroJSON/discussions/categories/neurojson-json-format-specifications-and-parsers

To sort the elements of a string/cell array use NATSORT: http://www.mathworks.com/matlabcentral/fileexchange/34464-customizable-natural-order-sortTo sort the rows of a string/cell array use NATSORTROWS: http://www.mathworks.com/matlabcentral/fileexchange/47433-natural-order-row-sortSummaryAlphanumeric sort the text in a string/cell/structure array. Sorts the text by character code taking into account the values of any number substrings. Compare for example:>> A = {'a2.txt', 'a10.txt', 'a1.txt'};>> sort(A)ans = 'a1.txt' 'a10.txt' 'a2.txt'>> natsortfiles(A)ans = 'a1.txt' 'a2.txt' 'a10.txt'By default NATSORTFILES interprets all consecutive digits as integer numbers, the number substring recognition can be specified using a regular expression: see NATSORT for details.NATSORTFILES does not perform a naive natural-order sort, but sorts the filenames and file extensions separately to ensure a dictionary sort, where shorter filenames always sort before longer ones. Likewise filepaths are split at each file-separator character, and each level of the file hierarchy is sorted separately.Example with DIR()P = 'C:\SomeDir\SubDir';S = dir(fullfile(P,'*.txt'));S = natsortfiles(S);for k = 1:numel(S) F = fullfile(P,S(k).name)endFile DependencyThe natural-order sort is provided by the function NATSORT (File Exchange 34464). All of NATSORT's optional inputs are supported by NATSORTFILES.Examples>> A = {'a2.txt', 'a10.txt', 'a1.txt'}>> sort(A)ans = 'a1.txt' 'a10.txt' 'a2.txt'>> natsortfiles(A)ans = 'a1.txt' 'a2.txt' 'a10.txt'>> B = {'test2.m'; 'test10-old.m'; 'test.m'; 'test10.m'; 'test1.m'};>> sort(B) % Wrong number order:ans = 'test.m' 'test1.m' 'test10-old.m' 'test10.m' 'test2.m'>> natsortfiles(B) % Shorter names before longer:ans = 'test.m' 'test1.m' 'test2.m' 'test10.m' 'test10-old.m'%% Directory Names:>> C = {'A2-old\test.m';'A10\test.m';'A2\test.m';'A1\test.m';'A1-archive.zip'};>> sort(C) % Wrong number order, and '-' sorts before '\':ans = 'A1-archive.zip' 'A10\test.m' 'A1\test.m' 'A2-old\test.m' 'A2\test.m'>> natsortfiles(C) % Shorter names before longer:ans = 'A1\test.m' 'A1-archive.zip' 'A2\test.m' 'A2-old\test.m' 'A10\test.m'>> D = {'A1\B', 'A+/B', 'A/B1', 'A=/B', 'A\B0'};>> sort(D)ans = 'A+/B' 'A/B1' 'A1\B' 'A=/B' 'A\B0'>> natsortfiles(D)ans = 'A\B0' 'A/B1' 'A1\B' 'A+/B' 'A=/B'>> F = {'test_new.m'; 'test-old.m'; 'test.m'};>> sort(F) % Note '-' sorts before '.':ans = 'test-old.m' 'test.m' 'test_new.m'>> natsortfiles(F) % Shorter names before longer:ans = 'test.m' 'test-old.m' 'test_new.m'

English Description: Generally, in finite element models degree-of-freedom of all nodes be equals. But, a Heterosis finite element model has each of the corners are assumed to possess three degree-of-freedom (one displacement two rotation w,Qxx,Qyy) and centroidal node has two degree-of-freedom (two rotation Qxx,Qyy). In this matlab sub-function application have produced automatic mesh function, position matrix, reology matrix and this matrix components (R and Re matrix) with modular-filter-technique. Turkish Description: Genellikle, sonlu eleman modellerinin tüm dügümlerinde esdeger serbetlik derecesi vardir. Fakat, bir Heterosis sonlu eleman modelinin, her bir kösesinde üç adet serbetlik derecesine (bir deplasman, iki dönme w,Qxx,Qyy) ve merkezi dügüm noktasinda iki adet serbestlige (Qxx,Qyy) sahiptir. Bu Matlab alt-program uygulamasinda otomatik ag fonksiyonu, konum matrisi ve reoloji matrisi ve bu matrisin bilesenleri (R ve Re matrisi) modüler filtreleme teknigi ile türetilmistir.Syntax:mesh_x = "x" axis direction total mesh value.mesh_y = "y" axis direction total mesh value.total_x = "x" axis direction total length.total_y = "y" axis direction total width.Cor = In global cartesian system all nodes coordinates (xi,yi)Pos = All nodes position matrisi for each finite elementR,Re = Reology matrix components. freedom = System total degree-of-freedom. Example:[A,B,C,D]=Heterosis(2,3,1,0.5) <----| A = -0.5000 -0.2500 0 -0.2500 0.5000 -0.2500 1.0000 -0.2500 1.5000 -0.2500-0.5000 -0.0833..... ...... ......0.5000 0.75001.0000 0.75001.5000 0.7500B =1 3 13 11 2 8 12 6 73 5 15 13 4 10 14 8 911 13 23 21 12 18 22 16 1713 15 25 23 14 20 24 18 1921 23 33 31 22 28 32 26 2723 25 35 33 24 30 34 28 29C = size(6x27)Columns 22 through 27 ... 16 17 18 19 20 NaN... 21 22 23 24 25 NaN... 44 45 46 47 48 NaN... 49 50 51 52 53 NaN... 72 73 74 75 76 NaN... 77 78 79 80 81 NaND = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 NaN 21 22 23 24 25 NaN 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 NaN 49 50 51 52 53 NaN 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 NaN 77 78 79 80 81 NaN 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99Run-Times:tic;[A,B,C,D]=Heterosis (2,2,1,0.5);toc Elapsed time is 0.012970 s.tic;[A,B,C,D]=Heterosis(10,10,1,0.5);toc Elapsed time is 0.007256 s.tic;[A,B,C,D]=Heterosis(50,50,1,0.5);toc Elapsed time is 2.262299 s.tic;[A,B,C,D]=Heterosis(100,100,1,0.5);toc Elapsed time is 89.255372 s.

In this research work mainly concentrate to develop intelligent control based grid integration of hybrid PV-Wind power system along with battery storage system. The grid integration hybrid PV – Wind along with intelligent controller based battery management system [BMS] has been developed a simulation model in Matlab and analysis the system performance under normal condition. The same system has been simulated with UPFC and analysed the system performance under different fault condition.https://www.youtube.com/watch?v=NbzBKOErcIE

A set of two code, i.e., LDVProcessorFFT and LDVProcessorLomb calculates the power spectral density of evenly and unvenly sampled experimental data with inherent noise, respectively. Fast Fourier transform and Lomb–Scargle method is used to calculate the power spectral density. The power spectral density is then averaged over logarithmically spaced bins, the noise floor is identified and a power-law is fitted to it. The power-law fit is then extrapolated and subtratcted from the entire power spectrum to remove the noise from the enitre spectrum. References:(1) W. H. Press, S. A. Teukolsky, B. P. Flannery, and W. T. Vetterling, Numerical recipes in Fortran 77: the art of scientific computing, volume 1 (Cambridge university press, 1992).(2) Yamani, S., Raj, Y., Zaki, T.A., McKinley, G.H. and Bischofberger, I., 2022. Spatio-temporal Signatures of Elasto-inertial Turbulence in Viscoelastic Planar Jets. arXiv preprint arXiv:2207.10736.

(More information is available at the homepage of PDFO: https://www.pdfo.net ; the paper describing PDFO is available at https://arxiv.org/abs/2302.13246 ; check also PRIMA at http://www.libprima.net )PDFO (Powell's Derivative-Free Optimization solvers) is a cross-platform package providing interfaces for using the late Professor M. J. D. Powell's derivative-free optimization solvers, including UOBYQA, NEWUOA, BOBYQA, LINCOA, and COBYLA, which were originally implemented in Fortran 77.PDFO provides a MATLAB function named pdfo. It can automatically identify the type of your problem and then call one of Powell's Fortran solvers. The pdfo function is designed to be compatible with the fmincon function available in the Optimization Toolbox of MATLAB. You can call pdfo in the same way as calling fmincon:x = pdfo(fun, x0)x = pdfo(fun, x0, A, b)x = pdfo(fun, x0, A, b, Aeq, beq)x = pdfo(fun, x0, A, b, Aeq, beq, lb, ub)x = pdfo(fun, x0, A, b, Aeq, beq, lb, ub, nonlcon)x = pdfo(fun, x0, A, b, Aeq, beq, lb, ub, nonlcon, options)x = pdfo(problem) % PROBLEM is a structure defining the optimization problem[x, fval] = pdfo(___)[x, fval, exitflag, output] = pdfo(___)In addition, pdfo can be called in some flexible ways that are not supported by fmincon. If your problem can be solved by fmincon without specifying the derivatives, then it can probably be better solved by pdfo; if your problem cannot be solved by fmincon, then try pdfo. Professor Powell ( https://en.wikipedia.org/wiki/Michael_J._D._Powell ) devised these derivative-free optimization solvers to tackle general nonlinear optimization problems of continuous variables with or without constraints using only function values but not derivatives of the objective function or nonlinear constraint functions. In practice, such functions are often black boxes defined by simulations. Consequently, the corresponding optimization problems are often categorized as black-box optimization or simulation-based optimization. Problem specified by explicit formulas can probably be handled by other methods more efficiently. UOBYQA and NEWUOA can solve unconstrained problems, NEWUOA being preferable except for rather small problems; BOBYQA can solve unconstrained and bound-constrained problems; LINCOA can solve unconstrained, bound-constrained, and linearly constrained problems; COBYLA, which is not recommended unless nonlinear constraints are present, can solve general nonlinear optimization problems. See the Decision Tree for Optimization Software for more information.The current version of PDFO supports MATLAB and Python. It relies on MEX for MATLAB and F2PY for Python to compile the Fortran solvers and wrap them into user-friendly functions.Based on Professor Powell's Fortran code, PDFO is developed by Tom M. Ragonneau and Zaikun Zhang at the Department of Applied Mathematics, the Hong Kong Polytechnic University.For more information, see the homepage of PDFO: https://www.pdfo.net .PDFO is dedicated to the late Professor M. J. D. Powell FRS (1936--2015).

ScrollPlot adds a scroll sub-window to any supplied plot handles (or current [gca] axes if no handle was supplied). This enables easy plot or image exploration. The user can specify initial view window parameters or use the defaults.Dragging the side-bars or central patch modifies the parent axes limits interactively. Conversely, modifying the parent axes limits (with zoom, pan or programatically) modifies the corresponding scroll patch(es) accordingly.Both X & Y scrolling are possible.Custom properties provide access to the scroll axes, central patch and side-bars, for user customizations (e.g., color, patch opacity level, side-bar line-width, etc.).ScrollPlot works on Matlab 6 (R12) and up.Syntax: scrollHandles = scrollplot(plotHandles, propName,propValue,...)Examples: >> scrollplot; % add scroll sub-window to the current axes (gca) >> scrollplot(plot(xdata,ydata), 'WindowSize',50); % plot with initial zoom >> scrollplot('Min',20, 'windowsize',70); % add x-scroll to current axes >> scrollplot([h1,h2], 'axis','xy'); % scroll both X&Y of 2 plot axes >> scrollplot('axis','xy', 'minx',20, 'miny',10); % separate scroll minimaSee extensive help within.Warning:This code relies in [small] part on undocumented and unsupported Matlab functionality. It works on Matlab 6+, but use at your own risk!Bugs and suggestions:Please send to Yair Altman (altmany at gmail dot com)Change log:See the bottom of this webpageThis ScrollPlot was inspired by Steve Lord's scrollplot demo submission, but is an entirely new implementation with lots of new functionality.

exportToPPTX allows user to create PowerPoint 2007+ (PPTX) files without using COM-objects automation (or PowerPoint application itself). Proper XML files are created and packaged into PPTX file that can be read and displayed by PowerPoint.Basic command syntax:pptx = exportToPPTX();pptx.(...)List of available commands:* pptx = exportToPPTX(...)* pptx = exportToPPTX(file)* pptx.save(file)* pptx.addSlide(...)* pptx.switchSlide(slideID)* pptx.addPicture(h,...)* pptx.addTextbox(txt,...)* pptx.addNote(txt,...)* pptx.addShape(x,y,...)* pptx.addTable(tbl,...)More elaborate examples are included in examples_exportToPPTX.m and examples2_exportToPPTX.m files.Up-to-date version, a more detailed help, bugs/issues tracking can all be found here: https://github.com/stefslon/exportToPPTX

This is matlab2tikz, a MATLAB(R) script for converting MATLAB figures into native TikZ/Pgfplots figures.matlab2tikz supports the conversion of most MATLAB figures, including 2D and 3D plots. For plots constructed with third- party packages, your mileage may vary.The workflow is as follows.a. Place the matlab2tikz scripts (contents of src/ folder) in a directory where MATLAB can find it (the current directory, for example). b. Make sure that your LaTeX installation includes the packagesTikZ (aka PGF, >=2.00) andPgfplots (>=1.3).Generate your plot in MATLAB.Invoke matlab2tikz by```>> matlab2tikz();```or```>> matlab2tikz('myfile.tex');```The script accepts numerous options; check them out by invoking the help,```>> help matlab2tikz```Sometimes, MATLAB makes it hard to create matching LaTeX plots by keeping invisible objects around or stretches the plots too far beyond the bounding box. Use```>> cleanfigure;>> matlab2tikz('myfile.tex');```to first clean the figure of unwanted entities, and then convert it to TeX.Add the contents of `myfile.tex` into your LaTeX source code; a convenient way of doing so is to use `\input{/path/to/myfile.tex}`. Also make sure that at the header of your document the Pgfplots package is included:```\documentclass{article}\usepackage{pgfplots}% and optionally (as of Pgfplots 1.3):\pgfplotsset{compat=newest}\pgfplotsset{plot coordinates/math parser=false}\newlength\figureheight\newlength\figurewidth\begin{document}\input{myfile.tex}\end{document}```There are reported incompatibilities with the following LaTeX packages:signalflowdiagram http://www.texample.net/tikz/examples/signal-flow-building-blocks/ (Check out http://sourceforge.net/tracker/?func=detail&aid=3312653&group_id=224188&atid=1060656.)If you experience bugs, have nice examples of what matlab2tikz can do, or if you are just looking for more information, please visit the web page of matlab2tikz https://github.com/matlab2tikz/matlab2tikz.

# Dickey-Fuller GLS test for MATLABThe MATLAB DFGLS function implements unit-root testing using the DF-GLS test of Elliott, Rothenberg & Stock (1996), allowing for 3 methods for choosing the optimal lag-length in the underlying Augmented Dickey-Fuller (ADF) regression. The methods for selecting the optimal number of lags are: * SIC, * MAIC by Ng-Perron (2001), and the * Sequential t-test by Ng-Perron (1995).> [!NOTE]> For a quick tutorial and a comparison to Stata®'s dfgls function, see the [Examples](https://viewer.mathworks.com/?viewer=live_code&url=https%3A%2F%2Fwww.mathworks.com%2Fmatlabcentral%2Fmlc-downloads%2Fdownloads%2Ffe77d215-53b0-4ed8-9c62-67a9e8aa63ac%2F244d249e-f7df-4eaa-9238-853bcf3d3416%2Ffiles%2Ftutorial_dfgls.mlx&embed=web) section in [File Exchange](https://uk.mathworks.com/matlabcentral/fileexchange/170951-dfgls-for-matlab), or the included .mlx file.

Create standalone Functional Mock-up Units (FMUs) from your design with FMU Builder for Simulink support package. The generated FMUs can be configured to be compliant with either FMI 2 or FMI 3 specifications. With FMU Builder, you can:Create standalone FMUs from Simulink models or C/C++ source code Create nested FMUsUse Structured I/O Signals and Runtime Tunable ParametersValidate Exported FMUs Integrate your Simulink model with third-party simulation environmentsFor more details on capabilities for this support package, please visit: https://www.mathworks.com/products/fmubuilder.html

This submission defines a class of N-dimensional sparse arrays for N possibly greater than 2. However, it should really be thought of as a way of starting with an ordinary MATLAB sparse matrix and reshaping it to have N dimensions. In other words, the sparse data must first be able to exist as an ordinary 2D MATLAB sparse matrix before being made N-dimensional. In fact, if the intended array has dimensions MxNxP...YxZ, then the class will store it internally as an ordinary 2D sparse array of dimensions (M*N*P*...*Y)xZ. This leads to certain memory strains when using large numbers of dimensions. I find the class useful mainly for moderate dimensional things like edge detection in 3D imaging, where you often want to hold a sparse 3D edge map. USAGE: S=ndSparse(X) where X is an ordinary MATLAB sparse matrix converts X into an ndSparse object. S can be reshaped into an N-dimensional sparse array using its RESHAPE method, for arbitrary N. S=ndSparse(X,[M,N,P,...]) is equivalent to reshape(ndSparse(X),[M,N,P,...]). The class also has a variety of static methods that can be used to construct instances of the class. For example, S=ndSparse.build(Coordinates,Values,[m,n,p,...],nzmax) lets you generate an N-dimensional sparse array from a table of explicit entries. This is a generalization to N dimensions of S=sparse(i,j,s,m,n,nzmax). Other such methods include: ndSparse.accumarray ndSparse.sprand ndSparse.sprandn ndSparse.spalloc EXAMPLES: >> A=ndSparse.build( [1 1 1; 2 1 1;2 2 2] , [50,60 70]) %Builds a 2x2x2 sparse array from table A(:,:,1) = (1,1) 50 (2,1) 60 A(:,:,2) = (2,2) 70Many of the same manipulations common to ordinary multidimensional MATLAB full arrays can be performed on the sparse 3D array A generated above. It can be permuted, summed, concatentated, and so forth e.g., >> B=sum( permute([A,A+10], [3,2,1]) ,2) B(:,:,1) = (1,1) 120 (2,1) 20 B(:,:,2) = (1,1) 140 (2,1) 160Other overloaded methods include BSXFUN, REPMAT, CIRCSHIFT, CONVN, FLIPDIMS, SQUEEZE, SHIFTDIM and many more. Type "methods ndSparse" for a full list and use "help ndSparse.methodname" to get details of usage. When browsing the list of methods, note that certain common operations have different implementations, optimized for different situations. Specifically, SUM, ANY,ALL, MIN, MAX... have alternative implementations SUMML, ANYML, ALLML, MINML, MAXML which are optimized for "low-dimensional" ndSparse objects OBJ. Here, low-dimensional means that a normal N-column MATLAB sparse matrix won't consume too much memory on your platform for N=MAX(NUMEL(OBJ)./SIZE(OBJ)). Another feature of the class is that bi-operand operations are allowed between ndSparse objects and MATLAB objects of any numeric type (single, uint16, etc...). This is not true of ordinary MATLAB sparse matrices, as of R2010b. >> C=eye(2,'single')*B(:,:,2) C = (1,1) 140 (2,1) 160 >> whos A B C Name Size Bytes Class Attributes A 2x2x2 136 ndSparse B 2x1x2 140 ndSparse C 2x1 104 ndSparse To convert back to an ordinary n-D full array, use the class' overloaded FULL method. To convert to a normal 2D sparse matrix, use the methods SPARSE or SPARSE2D. For example, SPARSE2D will convert an MxNxPx...xQ ndSparse array to the two dimensional (M*N*P*...)xQ sparse matrix in native MATLAB form.

Partial sums of Fourier terms for a function with jumps in value or derivative converge poorly, because of the Gibbs phenomenon. This file uses the Fourier coefficients, and locations of the singularities, to construct a different approximation that converges spectrally. For details, see T. A. Driscoll and B. Fornberg, Numerical Algorithms 26 (2001), pp. 77-92.Example for f(x)=|x|, using 7 Fourier coefficients:c = [pi/4 zeros(1,11)];c(2:2:12) = -(2/pi)*(1:2:11).^(-2);z0 = exp(1i*[-pi 0]);[p,q,r] = padelog(c,z0);% Make a plot:x = linspace(-pi+10*eps,pi-10*eps,200); z = exp(1i*x);pz = polyval(p(end:-1:1),z);qz = polyval(q(end:-1:1),z);rz{1} = polyval(r{1}(end:-1:1),z);rz{2} = polyval(r{2}(end:-1:1),z);fplus = ( pz + rz{1}.*log(1-z/z0(1)) + rz{2}.*log(1-z/z0(2)) ) ./ qz;plot(x,abs(x),x,2*real(fplus),'k.')

=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~[WARNING] This is a Java package, downloading via FileExchange will get you only the source code.=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~[INSTRUCTIONS]* https://github.com/GavriYashar/Matlab-Editor-Plugin/releases* Follow the link download both*.jar filesmatconsolectl-4.4.2.jar and MEP_1.33.jar* Follow the instructions on the wiki page (https://github.com/GavriYashar/Matlab-Editor-Plugin/wiki/Setup)* might work with earlier releases=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~[FEATURES]* https://github.com/GavriYashar/Matlab-Editor-Plugin/wiki/Features[SHORT SUMMARY]In short, it will mess around with Matlab's Editor.### Edit CodeClipboardStack(https://github.com/GavriYashar/Matlab-Editor-Plugin/wiki/Features#clipboard-stack)Duplicate line(https://github.com/GavriYashar/Matlab-Editor-Plugin/wiki/Features#duplicate-or-remove-current-line)Delete line(https://github.com/GavriYashar/Matlab-Editor-Plugin/wiki/Features#duplicate-or-remove-current-line)Moving current lines up(https://github.com/GavriYashar/Matlab-Editor-Plugin/wiki/Features#moving-current-lines-up-or-down)Moving current lines down(https://github.com/GavriYashar/Matlab-Editor-Plugin/wiki/Features#moving-current-lines-up-or-down)LiveTemplatesViewer(https://github.com/GavriYashar/Matlab-Editor-Plugin/wiki/Live-Templates)### NavigationNavigation History(https://github.com/GavriYashar/Matlab-Editor-Plugin/wiki/Features#navigation-history)Auto-Detail-Viewer(https://github.com/GavriYashar/Matlab-Editor-Plugin/wiki/Features#auto-detail-viewer--switch-current-folder)Auto-Switch-Current-Folder(https://github.com/GavriYashar/Matlab-Editor-Plugin/wiki/Features#auto-detail-viewer--switch-current-folder)FileStructure(https://github.com/GavriYashar/Matlab-Editor-Plugin/wiki/Features#file-structure)BookmarkViewer(https://github.com/GavriYashar/Matlab-Editor-Plugin/wiki/Features#bookmarks)Recently Closed Editor(https://github.com/GavriYashar/Matlab-Editor-Plugin/wiki/Features#recently-closed-editor)### OtherKeyPressListener(https://github.com/GavriYashar/Matlab-Editor-Plugin/wiki/Setup#creating-custom-key-press-callbacks-in-editor)Execute Current Line(https://github.com/GavriYashar/Matlab-Editor-Plugin/wiki/Features#execute-current-lines)VarDiff(https://github.com/GavriYashar/Matlab-Editor-Plugin/wiki/Features#vardiff)* Shortcuts can be changed in `*.properties` file* Windows are dockable## Setuphttps://github.com/GavriYashar/Matlab-Editor-Plugin/wiki/Setup## Featureshttps://github.com/GavriYashar/Matlab-Editor-Plugin/wiki/Features## FAQhttps://github.com/GavriYashar/Matlab-Editor-Plugin/wiki/FAQ## contactgavriyashargithub@gmail.com=~-~=~-~=~-~=~-~=~-~=~-~=~-~=~-~[RELEASE NOTES]https://github.com/GavriYashar/Matlab-Editor-Plugin/wiki/Release-Notes

Syntax: count = cprintf(style,format,...)Description:CPRINTF processes the specified text using the exact same FORMAT arguments accepted by the built-in SPRINTF and FPRINTF functions.CPRINTF then displays the text in the Command Window using the specified STYLE argument. The accepted styles are those used for Matlab's syntax highlighting (see: File / Preferences / Colors / M-file Syntax Highlighting Colors), and also user-defined colors.The possible pre-defined STYLE names are: 'Text' - default: black 'Keywords' - default: blue 'Comments' - default: green 'Strings' - default: purple 'UnterminatedStrings' - default: dark red 'SystemCommands' - default: orange 'Errors' - default: light red 'Hyperlinks' - default: underlined blue 'Black','Cyan','Magenta','Blue','Green','Red','Yellow','White'STYLE beginning with '-' o '_' will be underlined. For example: '-Blue' => underlined blue, like 'Hyperlinks' '_Comments' => underlined greenSTYLE beginning with '*' will be bold (R2011b+ only). For example: '*Blue' is bold blue; '*Comments' is bold green etc.Note: Matlab does not currently support both bold and underline, only one of them can be used in a single cprintf command. But of course bold and underline can be mixed by using separate commands.STYLE colors can be specified in 3 variants: [0.1, 0.7, 0.3] - standard Matlab RGB color format in the range 0.0-1.0 [26, 178, 76] - numeric RGB values in the range 0-255 '#1ab34d' - Hexadecimal format in the range '00'-'FF' (case insensitive). 3-digit HTML RGB format is also accepted: 'a5f' = 'aa55ff'STYLE can be underlined by prefixing - : -[0,1,1] or '-#0FF' is underlined cyanSTYLE can be made bold by prefixing * : '*[1,0,0]' or '*#F00' is bold redSTYLE is case-insensitive and accepts unique (non-ambiguous) partial strings (for example, 'cy' instead of 'cyan').Usage examples (see results in the attached screenshot): cprintf; % displays the demo cprintf('text', 'regular black text'); cprintf('hyper', 'followed %s','by'); cprintf('key', '%d colored', 4); cprintf('-comment','& underlined'); cprintf('err', 'elements\n'); cprintf('cyan', 'cyan'); cprintf('_green', 'underlined green'); cprintf(-[1,0,1], 'underlined magenta'); cprintf('*blue', 'and *bold* (R2011b+ only)\n'); cprintf([1,0.5,0],'and multi-\nline orange\n');Bugs and suggestions:Please send to Yair Altman (altmany at gmail dot com)Warning:This code heavily relies on undocumented and unsupported Matlab functionality. It works on Matlab 7+, but use at your own risk!A technical description of the implementation can be found at: https://UndocumentedMatlab.com/articles/cprintfSee details & current limitations in the main help section

This software implements the fast continuous max-flow algorithm to 2D/3D multi-region image segmentation (Potts model). It provides three implementations: matlab, C and GPU (cuda based). All the source files are provided. So it is easy for you to incorporate the algorithms in your own applications.2D/3D multi-region image segmentation can be modeled as computing the multi-way cuts, i.e. Potts model, in the spatially continuous setting, and solved by its convex relaxation. The continuous max-flow formulation is dual/equivalent to such convex relaxed Potts model problem. On the other hand, it also leads to a new fast algorithm in numerics, i.e. the fast continuous max-flow algorithm. More details are given in the document CMFML_README.pdf. Wish this software would be helpful for you and your works!For image segmentation with two regions: foreground and background, the fast continuous max-flow algorithm can be downloaded through: http://www.mathworks.com/matlabcentral/fileexchange/34126which is simpler.Email Jing Yuan (cn.yuanjing@gmail.com) for the questions, comments and suggests. You are welcome to propose your ideas of improvements. Any contribution will be kindly acknowledged in CMFML_README.pdf.