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.

# 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/)**** ***Download the Matlab Toolbox Package (PIVlab.mltbx) on the releases page:https://github.com/Shrediquette/PIVlab/releases*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:** https://groups.google.com/g/pivlab** **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)Thanks to the [thousands of publications that use PIVlab for research](https://scholar.google.de/scholar?cites=819244312015141543)!

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.

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

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.

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.

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

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)

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

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.

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.

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.

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

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.

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.

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.

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/

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]

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-');

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)

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);

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)

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'

RES = SIMPSON(Y) computes an approximation of the integral of Y via Simpson's 1/3 rule (with unit spacing). Simpson's 1/3 rule uses quadratic interpolants for numerical integration. To compute the integral for spacing different from one, multiply RES by the spacing increment. For vectors, SIMPSON(Y) is the integral of Y. For matrices, SIMPSON(Y) is a row vector with the integral over each column. For N-D arrays, SIMPSON(Y) works across the first non-singleton dimension. RES = SIMPSON(X,Y) computes the integral of Y with respect to X using Simpson's 1/3 rule. X and Y must be vectors of the same length, or X must be a column vector and Y an array whose first non-singleton dimension is length(X). SIMPSON operates along this dimension. Note that X must be equally spaced for proper execution of the 1/3 and 3/8 rules. If X is not equally spaced, the trapezoid rule (MATLAB's TRAPZ) is recommended. RES = SIMPSON(X,Y,DIM) or SIMPSON(Y,DIM) integrates across dimension DIM of Y. The length of X must be the same as size(Y,DIM)). RES = SIMPSON(X,Y,DIM,RULE) can be used to toggle between Simpson's 1/3 rule and Simpson's 3/8 rule. Simpson's 3/8 rule uses cubic interpolants to accomplish the numerical integration. If the default value for DIM is desired, assign an empty matrix. - RULE options [DEFAULT] '1/3' Simpson's rule for quadratic interpolants '3/8' Simpson's rule for cubic interpolants Examples: % Integrate Y = SIN(X) x = 0:0.2:pi; y = sin(x); a = sum(y)*0.2; % Rectangle rule b = trapz(x,y); % Trapezoid rule c = simpson(x,y,[],'1/3'); % Simpson's 1/3 rule d = simpson(x,y,[],'3/8'); % Simpson's 3/8 rule e = cos(x(1))-cos(x(end)); % Actual integral fprintf('Rectangle Rule: %.15f\n', a) fprintf('Trapezoid Rule: %.15f\n', b) fprintf('Simpson''s 1/3 Rule: %.15f\n', c) fprintf('Simpson''s 3/8 Rule: %.15f\n', d) fprintf('Actual Integral: %.15f\n', e) % http://math.fullerton.edu/mathews/n2003/simpson38rule/Simpson38RuleMod/Links/Simpson38RuleMod_lnk_2.html x1 = linspace(0,2,4); x2 = linspace(0,2,7); x4 = linspace(0,2,13); y = @(x) 2+cos(2*sqrt(x)); format long y1 = y(x1); res1 = simpson(x1,y1,[],'3/8'); disp(res1) y2 = y(x2); res2 = simpson(x2,y2,[],'3/8'); disp(res2) y4 = y(x4); res4 = simpson(x4,y4,[],'3/8'); disp(res4) Class support for inputs X, Y: float: double, single See also sum, cumsum, trapz, cumtrapz.

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).

**HISTWEIGHT** bins scattered data points defined in any dimension weighting them into uniform bins of specified granularity. Each data point has an associated intensity value which is spread to the neighbouring bins with a weight defined by three different methods (invsquared, diff or area).Limits of binning can be defined, different for each dimension. The granularity downsample the limits and increase the number of bins. Examples of how the function works are depicted in the following figure. Granularity is set to 1 and area method is used for all of them.- 1-dimensional uniform points sampled from a sine wave with decreasing amplitude: ![sine_uniform](https://github.com/andrepiz/histweight/assets/75851004/56afe971-dcec-43c9-86b6-a13621537e0a)- 2-dimensional random points with two different intensities: ![points_random](https://github.com/andrepiz/histweight/assets/75851004/1e2d00f1-c823-49dc-b04d-40e37b5f7da4)- 2-dimensional random points sampled within a circle, with a larger intensity in a inner circle: ![circle_random](https://github.com/andrepiz/histweight/assets/75851004/b01b1dbc-c12b-4688-8932-7eee7ef04a15)- 3-dimensional uniform points sampled within a emisphere, with intensity increasing with the radius: ![emisphere_uniform](https://github.com/andrepiz/histweight/assets/75851004/77ccf275-854f-4b1d-aa4e-88adcade1f43)**WHY HISTWEIGHT?**The MATLAB function histcounts allows to bin scattered data points into quantiles and counts the number of points falling into each quantile.HISTWEIGHT improves histcounts by considering intensity values for each data point that are spread across the neighbouring quantiles. Note that in this way energy conservation is respected as the total sum of the intensity values associated to each point is equal to the total sum of the intensity values associated to each bin.This does not happen with MATLAB histcounts.THe following figures show a comparison of HISTWEIGHT against MATLAB histcounts using three different methods for a set of 10 randomly distributed points:- _invsquared_: inverse squared distance of each vertex with respect to the center of the bin ![invsquared](https://github.com/andrepiz/histweight/assets/75851004/f408528c-e8a7-4adb-ab95-c268d866234c)- _diff_: 1 minus distance of each vertex with respect to the center of the bin, normalized over maximum distance ![diff](https://github.com/andrepiz/histweight/assets/75851004/1c50ab79-f9cd-4dfd-bfcb-0f64e9be35aa)- _area_: fractions of a square box centered into the point that fall into each neighbouring bins ![area](https://github.com/andrepiz/histweight/assets/75851004/1209e072-9572-4dc8-9896-73cb8e977fe5)

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.

Engineers are at the heart of the design process of complex systems and must meet the challenges of competitiveness, innovation and performance on a daily basis. This cannot be done without integrating structured industrial processes, nor without mastery of modern modeling and simulation tools. At each stage of the design cycle, the methods used must enable the lowering of costs, a reduction in the risk of error and a minimizing of the impact of errors. At the heart of this process, digital modeling and simulation play a major role in allowing engineers to anticipate, understand and verify the analyses that they conduct throughout a project.Standard industrial procedures, such as the V-Model, fully integrate digital simulation through associated methods such as “Model Based Design”. Modern simulation tools facilitate the creation of complex global models integrating all of the components of a system and taking all interactions into account. This procedure is called multi-physics modeling. The real system may be advantageously replaced by its digital model in order to conduct test that mobilize significant human and material resources ahead of time. This procedure requires the availability of validated models that faithfully reproduce the behavior of real systems.This book will provide you with a multi-physics modeling approach that uses the functionalities and innovations of simulation software in order to make the modeling process quicker and more efficient. The simulation platform used is MATLAB/Simulink software, version 2015a.The work is intended to provide the keys to facilitate the global modeling of a system by creating the link between industrial methods and methods used in the engineer training cycle. This is illustrated by numerous examples in different technological domains (electric, hydraulic, mechanical...) and highlights the interconnection of physics domains. The fundamentals for all of the tools necessary to conduct this procedure are presented:•MATLAB•Simulink•Simscape•Simscape_Fluids•Simscape_Multibody•Simscape_Electronics•StatflowThis work suggests an introduction to their use and will not make you an expert in any of them. You may, on the other hand, use it to perceive their full potential, and exploit it in greater depth in accordance with the specific needs that you encounter in your modeling.Happy reading,

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.

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).

# 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.

LOWTRAN7 is an Air Force Research Laboratory (AFRL) atmosphere radiance and transmittance model published August, 1988. This project is a translation of the LOWTRAN7 Sun and Moon Models into matlab. It should be noted that LOWTRAN7 has been superceded by MODTRAN and SAMM. For quality Sun and Moon images, AFRL's CBSD models should be used instead. However, it has value as an educational model for K12 and undergraduate work. LOWTRAN 7 is a low-resolution propagation model and computer code for predicting atmospheric transmittance and sky thermal and scattered radiance from 0 to 50,000 cm- 1 at a resolution of 20 cm-1.In LOWTRAN7, direct or scattered light from either the Sun or the Moon can be calculated. The Sun's irradiance is interpolated from a spectrum, and an orbit correction is applied to compensate for Earth's orbital eccentricity. The Moon's irradiance is calculated using a mathematical model developed and published by Robert E. Turner, et al. (1975) NATURAL AND ARTIFICIAL ILLUMINATION IN OPTICALLY THICK ATMOSPHERES, Environmental Research Institute of Michigan, AD-A021 998, Contract No. DAAA21-74-C-0331. (A pdf of this document is included in this download.) The Moon model applies the spectral geometric albedo, as best as it was known in 1988, a phase factor, and the angular extent of the Moon, to the orbit-corrected solar spectrum. The results are shown in the project image.The script testSourceFunctions.m exercises all the functions that comprise the Sun and Moon models:SUN - input the wavenumber, output the exoatmosphere irradiance [W/m2 um]SUBSOL - compute the subsolar latitude/longitude for day of year and UTC code claims a 1 degree accuracyDEL - lowtran7 computes the source zenith angle along the line-of-sight for source scattered light, beta is the earth center angle from the observer to the point along the line-of-sightPSI - calculates the relative azimuth between line-of-sight and observer-Sun-path and the earth center angle between observer lat/lon and subsolar lat/lonSCTANG - compute the angle between the source rays and the line-of-sightPSIDEL - compute the earth-center angle between the observer lat/lon and the source lat/lon; compute the relative azimuth between the los and the observer->source pathSOURCE - get solar or lunar exoatmosphere irradiance (sun is factored by the sun-earth distance as determined by the day of year; moon is factored by spectral geometric albedo and phase)createBlockData_SUNDAT - makes a mat file with populated arrays of the block data that has the exoatmospheric solar spectrum in LOWTRAN7The solar spectrum, which was a FORTRAN block data, is coded as an array stored in a mat file. https://qph.fs.quoracdn.net/main-qimg-9f77fdcf3b9d432c49319cf428e3f7c6 The subsolar latitude and longitude are found from very simple equations claimed to be good to 1 degree accuracy:https://qph.fs.quoracdn.net/main-qimg-d9551a76906145926b15a20b290e5de9The lunar irradiance phase factor will work for any spherical, exoatmospheric body:https://qph.fs.quoracdn.net/main-qimg-ac16fe747338e964daa5c284324ef358 The Moon's spectral geometric albedo is as best as they knew it in the late 1980s:https://qph.fs.quoracdn.net/main-qimg-251a38454666cfb9ba25aac3a8dc90c4

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.

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

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.')

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

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.

This new support package helps you adopt and optimize Continuous Integration / Continuous Delivery (CI/CD) Workflows for Model-Based Design. With it you can address common challenges including setting up a pipeline tailored for Model-Based Design, reducing build time, reducing build failures, debugging build failures, and deploying a Model-Based Design workflow to the team and CI system. The support package provides: Customizable process modeling system to define your build and verification process Build system to generate and optimally execute the process in your CI systemProcess Advisor app to deploy and automate your prequalification processExamples for integration with common CI systems such as Jenkins or GitLab The support package analyzes your project and generates a Model-Based Design CI/CD Pipeline based on your own process definition. You can reduce build times by performing optimized builds in popular CI systems such as Jenkins or GitLab. You can prequalify your work in Simulink to reduce build failures in CI. If a failure occurs in CI, you can bring the results back into Simulink to reproduce and debug the issue. This package is under active development, please share your insight, questions, and experiences to aid future updates by contacting us at continuous-integration@mathworks.com. Prerequisites: The support package requires MATLAB® version R2022a Update 4 and later updates, and requires the use of MATLAB Projects, see Projects.You can use Process Advisor on your desktop without a CI system.To integrate the build system provided in this support package into your CI/CD system, you first need to configure your CI system to run MATLAB and Simulink products. For an example on how configure Jenkins and GitLab, see Continuous Integration for Verification of Simulink Models. For information on the supported platforms, see Continuous Integration with MATLAB on CI Platforms Documentation: Online documentationUser’s GuideReference BookGetting Started: You can install this support package from Add-On Explorer or by downloading from File Exchange. If downloading from File Exchange, double click the .mlpkginstall file to begin the installation. If you receive an error about the support package not being compatible with your version of MATLAB but you have R2022a installed, then check that the .mlpkginstall file is associated with MATLAB R2022a. The Process Advisor app runs on MATLAB projects. Process Advisor can be opened for an existing model in your project or the project itself. To open for an existing model in a project, on the Apps tab of the model, under Model Verification, Validation, and Test, click Process Advisor, see the image below. To open for a project, click Process Advisor app on the Project tab, see image below:An example project is provided to demonstrate the capabilities of Process Advisor. To open the project, MATLAB command line with the command: >>processAdvisorExampleStart Limitations: The incremental build technology and task staleness detection are under active development. Tasks will not become outdated when changing untracked artifacts. See Troubleshoot Missing Tasks, Artifacts, and Dependencies to see the list of untracked artifacts. These limitations are planned to be removed in future updates to the support package. Follow this File Exchange page to be notified of updates. Version HistoryCurrent version for MATLAB R2022a: February 2024, version 22.1.13.Current version for MATLAB R2022b: June 2024, version 22.2.16.Current version for MATLAB R2023a: June 2024, version 23.1.16.Current version for MATLAB R2023b: June 2024, version 23.2.6.Current version for MATLAB R2024a: June 2024, version 24.1.3.

Weighted correlation and covariance (weightedcorrs)Python, Jupyter notebook, and MATLAB function to calculate weighted correlation coefficients, covariance, and standard deviationsInstallation for MATLABDownload the weightedcorrs.m file from this github repository (https://github.com/gjpelletier/weightedcorrs) or MATLAB File Exchange and copy it to your working directory or session search path folder.Installation for Python, Jupyter Notebook, and Google ColabFirst install weightedcorrs as follows with pip or !pip in your notebook or terminal:pip install git+https://github.com/gjpelletier/weightedcorrs.gitNext import the weightedcorrs function as follows in your notebook or python code:from weightedcorrs import weightedcorrsAs an alternative, you can also download weightedcorrs.py from this github repository (https://github.com/gjpelletier/weightedcorrs) and add it to your own project.Syntax for MATLABSYNTAX:[R,p,wcov,wstd,wmean] = weightedcorrs(X,w)List of outputs:'R' is the output of the weighted Pearson correlation coefficients calculated from an input nobs-by-nvar matrix X whose rows are observations and whose columns are variables and an input nobs-by-1 vector w of weights for the observations. This function may be a valid alternative to MATLAB's corrcoef if observations are not all equally relevant and need to be weighted according to some theoretical hypothesis or knowledge.'p' is the output of the p-values of the Pearson correlation coefficients'wcov' is the output of the weighted covariance matrix'wstd' is the output of the weighted standard deviations'wmean' is the output of the weighted meansInput of w is optional. If w=0, 1, or is omitted, then the function assigns w = np.ones(nobs). If w=0 or omitted, then the covariance and standard deviations are unweighted and normalizd to nobs-1, and the means are unweighted. If w=1, then the covariance and standard deviations are unweighted and normlizd to nobs, and the means are unweighted. Otherwise, if w is an input vector of weights, then results are normalized to nobs for output of standard deviations and covariance, and the means are weighted by w. If w=0 or omitted, or if the input vector of w = ones(nobs,1), then there is no difference between weightedcorrs(X, w) and corrcoef(X).Syntax for Google Colab, Jupyter Notebooks, and PythonSYNTAX:results = weightedcorrs(X,w)weightedcorrs returns a results dictionary that contains the following outputs: R, p, wcov, wstd, and wmean.results['R'] is the output of the weighted Pearson correlation coefficients calculated from an input nobs-by-nvar matrix X whose rows are observations (nobs) and whose columns are variables (nvar), and an input nobs-by-1 vector w of weights for the observations. This function may be a valid alternative to np.corrcoef if observations are not all equally relevant and need to be weighted according to some theoretical hypothesis or knowledge.results['p'] is the output of the p-values of the Pearson correlation coefficientsresults['wcov'] is the output of the weighted covariance matrixresults['wstd'] is the output of the weighted standard deviationsresults['wmean'] is the output of the weighted meansInput of w is optional. If w=0, 1, or is omitted, then the function assigns w = np.ones(nobs). If w=0 or omitted, then the covariance and standard deviations are unweighted and normalizd to nobs-1, and the means are unweighted. If w=1, then the covariance and standard deviations are unweighted and normlizd to nobs, and the means are unweighted. Otherwise, if w is an input vector of weights, then results are normalized to nobs for output of standard deviations and covariance, and the means are weighted by w. If w=0 or omitted, or if the input vector of w = np.ones(nobs), then there is no difference between weightedcorrs(X, w) and np.corrcoef(X,rowvar=False).Example for MATLABload hospitalX = [hospital.Weight hospital.BloodPressure];w = hospital.Age;[wrho,p,wcov,wstd,wmean] = weightedcorrs(X,w) wrho =1.0000 0.1554 0.23070.1554 1.0000 0.51040.2307 0.5104 1.0000p =0 0.1226 0.02090.1226 0 0.00000.0209 0.0000 0wcov =683.6229 27.4898 41.787527.4898 45.7666 23.918241.7875 23.9182 47.9886wstd =26.1462 6.7651 6.9274wmean =154.4530 122.9480 83.0643Example for Google Colab, Jupyter Notebook, and PythonThe first step is to install weightedcorrs from github as follows:!pip install git+https://github.com/gjpelletier/weightedcorrs.gitNext we need to import the weightedcorrs function and numpy as follows:from weightedcorrs import weightedcorrsimport numpy as npNow we are ready to show an example of doing an analysis of some data using weightedcorrs. We will use a data set from the MATLAB example data packages called 'hospital'. The X array will be a three column array, where the first column is the patient's weight, the second column is the systolic blood pressure, and the third column is the diastolic blood pressure.Note that weightedcorrs requires the first index of X to be rows of observations, and the second index to be columns of random variables.# First we assign the X array with the first index as random variables# and second index as observations (therefore we will need to transpose X after this):X = [np.array([176., 163., 131., 133., 119., 142., 142., 180., 183., 132., 128., 137., 174., 202., 129., 181., 191., 131., 179., 172., 133., 117., 137., 146., 123., 189., 143., 114., 166., 186., 126., 137., 138., 187., 193., 137., 192., 118., 180., 128., 164., 183., 169., 194., 172., 135., 182., 121., 158., 179., 170., 136., 135., 147., 186., 124., 134., 170., 180., 130., 130., 127., 141., 111., 134., 189., 137., 136., 130., 137., 186., 127., 176., 127., 115., 178., 131., 183., 194., 126., 186., 188., 189., 120., 132., 182., 120., 123., 141., 129., 184., 181., 124., 174., 134., 171., 188., 186., 172., 177.]), np.array([124., 109., 125., 117., 122., 121., 130., 115., 115., 118., 114., 115., 127., 130., 114., 130., 124., 123., 119., 125., 121., 123., 114., 128., 129., 114., 113., 125., 120., 127., 134., 121., 115., 127., 121., 127., 136., 117., 124., 120., 128., 116., 132., 137., 117., 116., 119., 123., 116., 124., 129., 130., 132., 117., 129., 118., 120., 138., 117., 113., 122., 115., 120., 117., 123., 123., 119., 110., 121., 138., 125., 122., 120., 117., 125., 124., 121., 118., 120., 118., 118., 122., 134., 131., 113., 125., 135., 128., 123., 122., 138., 124., 130., 123., 129., 128., 124., 119., 136., 114.]), np.array([93., 77., 83., 75., 80., 70., 88., 82., 78., 86., 77., 68., 74., 95., 79., 92., 95., 79., 77., 76., 75., 79., 88., 90., 96., 77., 80., 76., 83., 89., 92., 83., 80., 84., 92., 83., 90., 85., 90., 74., 92., 80., 89., 96., 89., 77., 81., 76., 83., 78., 95., 91., 91., 86., 89., 79., 74., 82., 76., 81., 77., 73., 85., 76., 80., 80., 79., 82., 79., 82., 75., 91., 74., 78., 85., 84., 75., 78., 81., 79., 85., 79., 82., 80., 80., 92., 92., 96., 87., 81., 90., 77., 91., 79., 73., 99., 92., 74., 93., 86.])]# Next we transpose X so that the first index is rows of observations (nobs),# and the second index is columns of random variables (nvar)X = np.transpose(X)Next we will define the weighting factors to use for the analysis. In this example we will use the patients Age from the hospital data set as the weighting factors w.w = np.array([38., 43., 38., 40., 49., 46., 33., 40., 28., 31., 45., 42., 25., 39., 36., 48., 32., 27., 37., 50., 48., 39., 41., 44., 28., 25., 39., 25., 36., 30., 45., 40., 25., 47., 44., 48., 44., 35., 33., 38., 39., 44., 44., 37., 45., 37., 30., 39., 42., 42., 49., 44., 43., 47., 50., 38., 41., 45., 36., 38., 29., 28., 30., 28., 29., 36., 45., 32., 31., 48., 25., 40., 39., 41., 33., 31., 35., 32., 42., 48., 34., 39., 28., 29., 32., 39., 37., 49., 31., 37., 38., 45., 30., 48., 48., 25., 44., 49., 45., 48.])Now we are ready to show the example of using weightedcorrs to calculate the weighted correlation coefficients, weighted covariance, and weighted standard deviations as follows:output = weightedcorrs(X,w)R = output['R']p = output['p']wcov = output['wcov']wstd = output['wstd']wmean = output['wmean']print('weighted correlation coefficient matrix of X: ','\n',R,'\n')print('p-values of the correlation coefficients: ','\n',p,'\n')print('weighted covariance matrix: ','\n',wcov,'\n')print('weighted standard deviations: ','\n',wstd,'\n')print('weighted means: ','\n',wmean)weighted correlation coefficient matrix of X:[[1. 0.1554138 0.23071152][0.1554138 1. 0.51036961][0.23071152 0.51036961 1. ]] p-values of the correlation coefficients:[[0.00000000e+00 1.22589252e-01 2.09237757e-02][1.22589252e-01 0.00000000e+00 5.81286900e-08][2.09237757e-02 5.81286900e-08 0.00000000e+00]] weighted covariance matrix:[[683.62291955 27.48984917 41.78750454][ 27.48984917 45.76662876 23.91817879][ 41.78750454 23.91817879 47.9885557 ]] weighted standard deviations:[26.14618365 6.76510375 6.92737726]weighted means:[154.45297806 122.94801463 83.06426332]Reference:The mathematical formulas in matrix notation, together withMATLAB code, is also available inF. Pozzi, T. Di Matteo, T. Aste,"Exponential smoothing weighted correlations",The European Physical Journal B, Volume 85, Issue 6, 2012.DOI:10.1140/epjb/e2012-20697-x.Adapted from weightedcorrs.m (Pozzi et al., 2012).Modified by Greg Pelletier 24-Jan-2024 to output p-values ofcorrelation coefficients, weighted covariance matrix, andweighted standard deviations, and allow optional input ofweighting factors for use with unweighted analysisor normalization to nobs-1

ThousandSep - Number as string with separators every 3rd digitS = ThousandSep(N, FSpec, Sep)INPUT: N: Numbers, all classes accepted by SPRINTF, scalar or array. FSpec: Format specifier for SPRINTF. Optional, default: '%.16g' Sep: Character as separator. Optional, default: ,OUTPUT: S: String if N is a scalar, otherwise a cell string.EXAMPLE: ThousandSep(1234567.2345) % '1,234,567.2345' ThousandSep(1234, char(39)) % '1'234' ThousandSep([2.3, 1234], ',') % {'2.3', '1,234'} ThousandSep(-1234, '%9.1f', ',') % ' -1,234.0' NOTES:* Alternative java call, which is about 20% slower (Matlab R2011b/64/Win7): nf = java.text.DecimalFormat; S = nf.format(1234567.890123)* Matlab 6: The code must be modified to run under Matlab 6. See the comment in the subfunction ToString. Tested: Matlab 7.7, 7.8, 7.13, WinXP/32, Win7/64

ISVALIDSYMBOL - Check string to be a valid Matlab symbolThis function is equivalent to Matlab's ISVARNAME, but accepts cell strings as input also. While the speed is comparable for strings, it is *much* faster for cell strings (see screenshot).L = isValidSymbol(S)INPUT: S: String or cell string.OUTPUT: L: LOGICAL scalar, if S is a string. LOGICAL array of the same size as S for a cell string. L is TRUE for valid symbols: The 1st character must be a letter, the following must be a letter, number or the underscore. The length must not exceed 63 characters.EXAMPLES: isValidSymbol('a') % >> true isValidSymbol('a1') % >> true isValidSymbol('a_') % >> true isValidSymbol({'_a', 'b'}) % >> [false, true] isValidSymbol('1a') % >> false s = repmat('a', 1, 63); isValidSymbol(s) % >> true isValidSymbol([s, 'a']) % >> falseAIM OF THIS SUBMISSION:Actually the C subfunction "CheckCString" was developed to support the safe creation of structs and MAT files in C-Mex functions. You can easily include the test to your Mex-projects - just remove the main function "mexFunction".For checking Matlab strings the conversion to a C-string wastes time. Therefore the subfunction "CheckMatlabString" operates on the mxChar-vector directly.You can accelerate Matlab's slow GENVARNAME remarkably by calling this function instead of a loop over ISVARNAME calls.COMPILATION: see isValidSymbol.cPRE-COMPILED MEX: http://www.n-simon.de/mexTEST: Run uTest_isValidsymbol to check validity and speed of the Mex function.Tested: Matlab 6.5, 7.7, 7.8, BCC5.5, LCC2.4/3.8, MSVC 2008, WinXP 32 bitSee also ValidSymbol, NAMELENGTHMAX, ISKEYWORD, ISVARNAME, GENVARNAME.

rsquared calculates the coefficient of determination (r2) from the original data (ydata) and fited data (yestimation). It also calculates the adjusted coefficient (r2adj) considering the number of parameters of the model (nparam). Syntax: r2 = rsquared(ydata,yestimation) [r2,r2adj]=rsquared(ydata,yestimation,nparam) Example: xdata = [1 5 14 23 25 48 49 59 73 77 99 ]; ydata = [-100 70 100 450 550 2200 2300 3400 5300 5906 9600]; plot(xdata,ydata,'ok'), hold on param_1 = polyfit(xdata,ydata,1); yestimation_1 = polyval(param_1,xdata); [r2_1,r2adj_1]=rsquared(ydata,yestimation_1,length(param_1)) plot(xdata,yestimation_1,'-r') param_2 = polyfit(xdata,ydata,2); yestimation_2 = polyval(param_2,xdata); plot(xdata,yestimation_2,'-b') [r2_2,r2adj_2]=rsquared(ydata,yestimation_2,length(param_2)) legend({'data',['r2=' num2str(r2_1) ', r2adj=' ... num2str(r2adj_1)],['r2=' num2str(r2_2) ', r2adj=' num2str(r2adj_2)]}, ... 'Location','best') Equations SSres=sum( (ydata-yestimation).^2 ); % residual sum of squares SStot=sum( (ydata-mean(ydata)).^2 ); % total sum of squares r2=1-SSres/SStot; % standard rsquared r2adj = 1 - SSres/SStot * (length(ydata)-1)/(length(ydata)-nparam); % adjust for the number of parameters Check https://en.wikipedia.org/wiki/Coefficient_of_determination

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%------------------------------------------------------------------------------------------------

freezeColors/unfreezeColorsfreezeColors allows multiple colormaps to be used per figure and even within a single axis.HistoryIn 2005 freezeColors was written to enable multiple colormaps in a single figure, something MATLAB could not do.It was a file exchange pick of the week in 2009.In 2014, MATLAB enabled each axis to have its own colormap. However, freezeColors still had a followingbecause it was more flexible and enabled multiple colormaps within a single axis as well.As MATLAB's graphics are continually evolving, over time freezeColors stopped working in some situations, such as with colorbars.Now, in 2022, it's been brought back up to date and will hopefully work in every use people have in mind. If not,let me know and I'll try to fix it.2022 Changes (v. 2.5)* greater emphasis on multiple colormaps within a single axis* new method for freezing colorbars* scatter works properly* works properly when calling freezeColors(axesHandle)* includes a replacement for colorbar: jicolorbarUsagefreezeColors applies to all objects in current axisfreezeColors(axh) same, but works on objects in axis axh.freezeColors(colorbar) creates a colorbar frozen to the current colormapExamplesMultiple colormaps per figure (legacy)subplot(2,1,1); imagesc(peaks); colormap hot; freezeColors; freezeColors(colorbar)subplot(2,1,2); imagesc(peaks); colormap hsv; freezeColors; freezeColors(colorbar) %etc...Note, in such a simple case, this could just as well use matlab's per-axis colormaps (2014 and later):subplot(2,1,1); imagesc(peaks); colorbar; colormap(gca,'hot')subplot(2,1,2); imagesc(peaks); colorbar; colormap(gca,'hsv')Here is an example (from test/test_main.m) alsoshowing one scatterplot panel using multiple colormaps in a single axis.Interesting: multiple colormaps in an axisfreezeColors can do something that some people need and not possible currently in MATLAB: having objects using multipledifferent colormaps within the same axis. These examples are somewhat contrived, but illustrate the possibilities.figuresurf(peaks); colormap parula; freezeColors; freezeColors(jicolorbar); hold onsurf(peaks+20); caxis([14 28]); colormap gray; freezeColors; freezeColors(colorbar);surf(peaks+40); caxis(caxis+20); colormap hot; freezeColors; freezeColors(jicolorbar('horiz'));axis auto; shading interp; caxis([14 28]); view([-27 14]); set(gca,'color',[.8 .8 .8])Example with surf and ribbonExample with streamribbon and coneplotSee test/test_main.m for more examples.How it worksThe color of some graphic objects in MATLAB is controled by a CData property (surf, image, scatter, patch, coneplot, streamribbon, etc), which is usually converted to color usingthe current colormap using a scaling process. Thus if the colormap changes, the appearance changes. freezeColors simply convertsall graphics objects from scaled CData to direct RGB CData meaning its appearance is 'frozen' to the current colormap and thussubsequent changes to the colormap will not change its appearance. The original scaled data are stored and can be restored using unfreezeColors.CaveatsIn its continued quest for improvement, some graphics objects change over time, foremost among them colorbars, which used to beimplemented as images and thus could easily be frozen along with other objects. Nowadays they are encapsulated in an opaque object andwe needed to find a new way to freeze them. Now simply call freezeColors(colorbar)to add a 'frozen' colorbar to an axis. It will appear to unfreeze when you change colormaps, but the next call to freezeColors willrestore its frozen appearance. It will not be frozen to the caxis, so be aware of that.It's a workaround, but just remember to call freezeColors after you change the colormaps andall will be well. This has the benefit of also freezing contourf plots, as long as you call freezeColors(colorbar) after the plot.Also, having multiple colorbars in an axis is a work in progress--a combination of jicolorbar and colorbar were used in the examplesand required some attention to setting the caxis; a more sustainable solution would be a new version of jicolorbar thatmore easily enables multiple (frozen) colorbars per axis...

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!

In order to run the program, the user must have an access to MATLAB R2017a or higher. Also the application requires the installation of Control Systems Toolbox. The plant is to be defined by the coefficients of the numerator and denominator polynomials of its transfer function. System's input delay and the feedback transfer function can now be taken into consideration in this new version.

A new Matlab interface for using the Ganymed-SS2 Java library. Renamed commands are improved for limitations of existing Matlab/SSH2 codebase (see inspired submissions) using a straightforward command list. If you need to access a remote machine from your Matlab session (for near-real time data transfer etc...) this set of functions allows you to send commands and obtain the return values. SFTP and SCP file transfer functions are included. Supports public key authentication and improved multiple command support. This requires the open-source Ganymed SSH-2 for Java that is freely available and automatically included in the zip file. For SFTP-GET, one must use the included custom Ganymed SSH-2 Java library that is compatible with Matlab. See ssh2-examples.m for documentation.FOR SUPPORT, PLEASE CONTACT AUTHOR DIRECTLY instead of posting to "Comments and Ratings" first. Helpful information or comments can be posted after communication to ensure useful information for others instead of a ballooning of failed SSH/SFTP/SCP connection info in the comments. #1 Problem with connections is software firewall on Matlab machine preventing Java from making connections. If you're able to connect with the same machine, please check for this.#2 Problem is supported authentication on ssh-server. Please see the Ganymed-SSH2 faq for more information. http://www.ganymed.ethz.ch/ssh2/FAQ.html Additionally, I would love to hear about how and where you're using this submission in the comments section.

usage:-------------------------------------------------------- [cc] = chaincode(b,u) INPUT:-------------------------------------------------------- b - boundary as np-by-2 array unwrap - (optional, default=false) unwrap code OUTPUT: -------------------------------------------------------- cc is a structure with the following fields: cc.code - 8-connected Freeman chain code 1-by-np cc.x0,cc.y0 - coordinates of start point cc.ucode - unwrapped 8-connected Freeman chain code

******************************Major Update Notification******************************Please visit the new, improved, GUI version of this program here:http://www.mathworks.com/matlabcentral/fileexchange/41464******************************Major Update Notification******************************This is a program which utilizes the included functions in order to calculate 8 image indices (Bias, Correlation coefficient, DIV, Entropy, ERGAS, Q, RASE and RMSE). The purpose of the program is to produce the results fast, easily and in a convenient way for the user (see Outputs). Initially, its purpose was to perform index analysis in hyperspectral and multispectral satellite imagery. It has been used and tested in fused hyperspectral products for quality assessment of the spectral fidelity. However, it is estimated that it can be used for image comparison of similar or processed images, of completely different origin. Every included function can be used separately.*For citation please go to bottom of description.*==================Program Structure:================== 0) User runs the program by typing 'imanalysis' in the command window. Inputs: 1) User must provide the program with the number (nin) of the test images (test) he desires to compare, with the original image (orig). *** All images must have the exact same resolution *** 2) After image inputs, user is being asked for the h/l ERGAS ratio. 3) Then, the user has to input the filenames, first that of the original image and afterwards, those of the (nin) test images declared in step 1. Index analysis: 4) Program performs computation of all eight indices for every image and for every band, by using seven independent functions. The average value is calculated for every index. Total values are also computed for Entropy, ERGAS and RASE indices. Outputs: 5) Program outputs an Excel file, containing each index analysis results in a homonymous spreadsheet. For ease, or later statistical operations, a column has been added to the left, numbering the bands of the tested imagery and a row above, containing the filename. User of course, can examine and plot the index results from Matlab command window. By typing before the index 'c' and after the index 's', the cell array containing the certain index is shown. For example, to display ERGAS index, we must type 'cergass'. See lines 326-333 in imanalysis, for every index (2nd arg in xlswrite). -Compatibility- -Oldest Matlab version tested: 7.0.1 (R14SP1). Bear in mind that you will not be able to analyze hyperspectral images with this version. -Oldest Matlab version known to have full functionality: 7.6 (R2008a). *This program does NOT use sliding windows in index computations.*------------------------------Citation / Link to paper------------------------------This is the citation and link to the study/paper, where you can find an application of the present program in fused hyperspectral and multispectral satellite imagery. If you are using this program for academic purposes, it would be very kind of you if you cite it properly:A. D. Vaiopoulos, "Developing Matlab scripts for image analysis and quality assessment", Proc. SPIE 8181, 81810B (2011); Link of the paper above:http://dx.doi.org/10.1117/12.897806 Link to program download (current page):http://www.mathworks.com/matlabcentral/fileexchange/32637