tag:la.mathworks.com,2005:/matlabcentral/fileexchange/feed?q=type%3AFunctionMATLAB Central File Exchangeicon.pnglogo.pngMATLAB Central - File Exchange - type:FunctionUser-contributed code library2020-02-17T14:33:31-05:0012811160542072020-01-20T16:20:23Z2020-01-20T16:20:23Zpolyfix(x,y,n,xfix,yfix,xder,dydx)Fit polynomial p to data, but match exactly at one or more points<p>Sometimes we want to fit a polynomial to some data, but want to force a perfect match to some known values at one or more points. This function returns such a polynomial.</p>Are Mjaavattenhttps://www.mathworks.com/matlabcentral/profile/3934907-are-mjaavatten721242019-08-01T11:55:40Z2019-08-01T11:55:40Zfft_plot functionPlot signal fft norm and phase versus frequency and signal versus time.Several options allows to customize the display<p>Plot signal fft norm and phase versus frequency and signal versus time. Function can also return fft results.optionnal input argument:- 'legend': 'signal name'- 'title': 'your title'- 'window': 'none', 'hann', 'hamming', 'flattop', 'blackman', 'blackmanharris'- 'subplot': 'fft', 'fft_signal', 'fft_angle', 'all', 'none'- 'MinNorm': if norm is lower than this value, angle is forced to 0.(angle makes no sense for small norm)- 'fmin': display frequency fmin to fs/2- 'fmax': display frequency 0 to fmax- 'Amax': display amplitude 0 to Amax- 'style': 'line', 'stem', 'bar', 'stairs', 'area', (fft norm only)- 'scale': 'linear', 'semilogx', 'semilogy', 'loglog' - 'linewidth': number (defaut is 0.5)</p>pierre-alexandre chauvenethttps://www.mathworks.com/matlabcentral/profile/9594986-pierre-alexandre-chauvenet700322019-10-24T08:05:32Z2019-10-24T08:05:32ZRobust Empirical Mode Decomposition (REMD)A useful adaptive signal processing tool for multi-component signal separation, non-stationary signal processing.<p>The REMD is an improved empirical mode decomposition powered by soft sifting stopping criterion (SSSC). The SSSC is an adaptive sifting stop criterion to stop the sifting process automatically for the EMD. It extracts a set of mono-component signals (called intrinsic mode functions) from a mixed signal. It can be used together with Hilbert transform (or other demodulation techniques) for time-frequency analysis.</p>Liu Zhilianghttps://www.mathworks.com/matlabcentral/profile/12638821-liu-zhiliang715962019-05-20T19:39:48Z2019-05-20T19:39:48ZPV characteristic IV curve plottingHere's a code to plot the characteristic IV curve of PV.<p>The function is used to calculate Isc and Voc in addition to plotting the characteristic IV curve.The functions takes the cell's parameters as inputs. The performance of the solar cell and its characteristic curves are determined by the cell's parameters.These Parameters are:- short circuit current density(J_sc), reverse saturation current density (J_o), Area (A), and ideality factor(If), Temparature in kelvin (T), Irradiance (G),series resistance(R_s) and shunt resistance(R_sh).An example;J_sc=34.3*10^-3;J_o=10*10^-10;A=pi*(3*2.5)^2;G=[1000,800,600];R_sh=100;R_s=0;T=298; If=1.5;Plot_IV(J_sc,J_o,A,T,If,G,R_sh,R_s)</p>Ibrahim Abouemirahttps://www.mathworks.com/matlabcentral/profile/6747513-ibrahim-abouemira720222019-07-03T01:55:58Z2019-07-03T01:55:58ZPOD - Proper Orthogonal Decomposition (Wrapper)By Fernando Zigunov, 2019 [U, S, V] = POD(X) returns the proper orthogonal decomposition<p>=====This function is just a nice wrapper for Matlab's built-in SVD function, whichonly operates in 2D data sets. The wrapper just reshapes the matricesbefore and after applying SVD such that the input series X can ben-dimensional and ensures the output modes U are also n-dimensional.=====%POD has several names (POD, SVD, PCA, ...) and is a mathematical tool that%highlights the principal modes of a random series of variables (i.e.,%financial measurements, fluid flow fields, structural vibrations, neuron%firing patterns, video frames, and basically anything imaginable!)%The POD tool is extremely useful in data analysis to identify the most%energetic modes of a complex system by simply performing measurements when%its operating. (But if you're already here you already know all of this.)%============Inputs:=============%X - Time series or snapshots to be analyzed. Can be a n-dimensional matrix%(n>=2). First dimension is time/snapshot, and all other dimensions are%conserved for output.%============Outputs:=============%U - Mode matrix, has the same size of X. First dimension of X was%"time/snapshot", therefore first dimension of U will be "mode". Modes are%automatically organized from most energetic U(1,:,:...) to least%energetic.%S - Mode eigenvalues. S.^2 gives the mode energies. S is a diagonal%matrix, so returns just the vector S to save one line of post-processing.%V - Mode time-series or snapshot coefficients - V contains the%contribution of each mode to a specific snapshot of X. U*S*V gives back X%(given U and X are reshaped into 2D matrices again).</p>Fernando Zigunovhttps://www.mathworks.com/matlabcentral/profile/10721836-fernando-zigunov240862019-05-20T13:57:49Z2019-05-20T13:57:49ZPolygon2VoxelConvert a triangulated mesh into a voxel volume<p>This function polygon2function will convert a Triangulated Mesh into a Voxel Volume which will contain the discretized mesh.Discretization of a polygon is done by splitting the polygon in smaller polygons, until the longest edge is smaller than 0.5 voxel, then the voxel beneath the vertice coordinates is set to one.Note, this new version is pure Matlab (previous version required c++ compiler)Try the example.Bugs, successes and other comments are welcome!</p>Dirk-Jan Kroonhttps://www.mathworks.com/matlabcentral/profile/1097878-dirk-jan-kroon714082019-12-15T01:50:42Z2019-12-15T01:50:42Zdfield8Interactive app to study a given first order ODE<p>This is a nice interactive tool to study first order ODEs, which was originally created by John Polking at Rice University (together with other tools such as pplane and odesolve).The original versions (up to dfield8 and pplane8) can be found here: <a href="https://math.rice.edu/~dfield/#8.0">https://math.rice.edu/~dfield/#8.0</a>, however they only work up to MATLAB versions R2014a. A great version of pplane8 which works in any MATLAB version can be found here: <a href="https://www.mathworks.com/matlabcentral/fileexchange/61636-pplaneNote">https://www.mathworks.com/matlabcentral/fileexchange/61636-pplaneNote</a> that at the time of writing there are a couple of versions (both called dfield9) from Gerardo Garcia (<a href="https://www.mathworks.com/matlabcentral/fileexchange/64437">https://www.mathworks.com/matlabcentral/fileexchange/64437</a>) and Iourii Kouznetsov (<a href="https://www.mathworks.com/matlabcentral/fileexchange/65886">https://www.mathworks.com/matlabcentral/fileexchange/65886</a>), however the former gives warnings for versions 2015a and later, and errors out for versions 2017b and later. The latter works without errors or warnings, but the text is disproportionally larger and out of place. Both versions have the toolbar on in the setup window and tend to place the display window a little out of reach in the upper right part of the screen sometimes.This version of dfield8 is the closest to the original in look and feel, but it works for any version from R2014b on.</p>Giampiero Campahttps://www.mathworks.com/matlabcentral/profile/1692307-giampiero-campa728142019-09-20T06:19:53Z2019-09-20T06:19:53ZMultivariate Variational Mode Decomposition (MVMD)The function MVMD applies the Multivariate Variational Mode Decomposition (MVMD) algorithm to multivariate or multichannel data.<p>The function MVMD applies the Multivariate Variational Mode Decomposition (MVMD) algorithm [1] to multivariate or multichannel data sets. The method is an alternative to another popular algorithm named Multivariate Empirical Mode Decomposition (MEMD). We have verified this code through simulations involving synthetic and real world data sets containing 2-16 channels. However, there is no reason that it shouldn't work for data with more than 16 channels.% Input and Parameters:% ---------------------signal - input multivariate signal that needs to be decomposedalpha - the parameter that defines the bandwidth of extracted modes (low value of alpha yields higher bandwidth)tau - time-step of the dual ascent ( pick 0 for noise-slack )K - the number of modes to be recoveredDC - true if the first mode is put and kept at DC (0-freq)init - 0 = all omegas start at 0 1 = all omegas start uniformly distributed 2 = all omegas initialized randomlytol - tolerance value for convergence of ADMM% Output:% --------------------- u - the collection of decomposed modes u_hat - spectra of the modes omega - estimated mode center-frequencies[1] N. Rehman, H. Aftab, Multivariate Variational Mode Decomposition, arXiv:1907.04509, 2019. </p>Naveed ur Rehmanhttps://www.mathworks.com/matlabcentral/profile/15035647-naveed-ur-rehman670182019-02-17T10:36:11Z2019-02-17T10:36:11Zk-Nearest Neighbors (kNN) AlgorithmComplete package<p>Function1. predict_knn2. find_knn3. plot_knnDescription1. Returns the estimated labels of one or multiple test instances and the accuracy of the estimates.2. Returns the k nearest training instances, the k nearest training labels and the respective distances.3. Creates a graphic highlighting the nearest training instances (For plotting, instances must have only two or three features (2-D or 3-D)).Examples using Iris Data Setload fisheririsX = meas;Y = species;Xnew = [min(X);mean(X);max(X)];k = 5;label = predict_knn(X,Y,Xnew,k)label = 'setosa' 'versicolor' 'virginica' Ynew = {'versicolor';'versicolor';'virginica'};[label,accuracy] = predict_knn(X,Y,Xnew,k,Ynew)label = 'setosa' 'versicolor' 'virginica' accuracy = 0.6667See more examples described in the script files.</p>David Ferreirahttps://www.mathworks.com/matlabcentral/profile/8649959-david-ferreira732462019-11-27T10:17:44Z2019-11-27T10:17:44ZPrincipal Component Analysis (PCA) on images in MATLAB (GUI)Principal Component Analysis (PCA) on images in MATLAB (GUI)<p>First, upload a colour image by clicking on the “upload an image button”. The acceptable image formats are png, jpg, jpeg, img and tif. Then click on the "Plot the grayscale image". After that enter the no. of PC's up to which you want to retrieve the images (both colour and grayscale).An error message/box will pop-up when you enter a number greater than the no. of PCs for that particular image. Also, an error will message will pop-up when the entered input is not a number.Enjoy!!!</p>ABHILASH SINGHhttps://www.mathworks.com/matlabcentral/profile/5569287-abhilash-singh658232019-04-04T10:22:02Z2019-04-04T10:22:02Zkmeans_opttries k-means over different number of clusters<p>k-means is a decent clustering algorithm, however it requires the specification of the number of clusters, and is stochastic.This function takes a matrix as input, as well as the maximum number of clusters, the cutoff to determine the best model (the fraction of variance explained), and makes sure the results are stable by repeating a number of times specified by the user.The above method is called the Elbow method.</p>Sebastien De Landtsheerhttps://www.mathworks.com/matlabcentral/profile/6296873-sebastien-de-landtsheer725342019-10-31T14:20:46Z2019-10-31T14:20:46ZKuramoto's model of synchronizing oscillatorsThe Kuramoto model is a nonlinear dynamic system of coupled oscillators that initially have random natural frequencies and phases.<p>The Kuramoto model is a nonlinear dynamic system of coupled oscillators that initially have random natural frequencies and phases. If the coupling is strong enough, the system will evolve to one with all oscillators in phase. See Cleve's Corner, <a href="https://blogs.mathworks.com/cleve/2019/10/30/stability-of-kuramoto-oscillators/">https://blogs.mathworks.com/cleve/2019/10/30/stability-of-kuramoto-oscillators/</a></p>Cleve Molerhttps://www.mathworks.com/matlabcentral/profile/349729-cleve-moler703152019-02-16T07:07:54Z2019-02-16T07:07:54ZSMOTE-over-SamplingThis repository is for MATLAB code for balancing of multiclass data by SMOTE<p>This repository is for MATLAB code for balancing of multiclass data by SMOTE. This is the MATLAB implementation of Synthetic Minority Oversampling Technique (SMOTE) to balance the unbalanced data. The paper followed for this is <a href="https://arxiv.org/pdf/1106.1813.pdf">https://arxiv.org/pdf/1106.1813.pdf</a>. We have updated this work for multiclass dataset.</p>Abhishek Guptahttps://www.mathworks.com/matlabcentral/profile/4196792-abhishek-gupta546812020-01-31T18:22:11Z2020-01-31T18:22:11ZFeature fusion using Canonical Correlation Analysis (CCA)Feature level fusion using Canonical Correlation Analysis (CCA)<p>Feature fusion is the process of combining two feature vectors to obtain a single feature vector, which is more discriminative than any of the input feature vectors. CCAFUSE applies feature level fusion using a method based on Canonical Correlation Analysis (CCA). It gets the train and test data matrices from two modalities X and Y, and consolidates them into a single feature set Z. Details can be found in: M. Haghighat, M. Abdel-Mottaleb, W. Alhalabi, "Fully Automatic Face Normalization and Single Sample Face Recognition in Unconstrained Environments," Expert Systems With Applications, vol. 47, pp. 23-34, April 2016. <a href="http://dx.doi.org/10.1016/j.eswa.2015.10.047">http://dx.doi.org/10.1016/j.eswa.2015.10.047</a> (C) Mohammad Haghighat, University of Miami <a href="mailto:haghighat@ieee.org">haghighat@ieee.org</a> PLEASE CITE THE ABOVE PAPER IF YOU USE THIS CODE.</p>Mohammad Haghighathttps://www.mathworks.com/matlabcentral/profile/2857455-mohammad-haghighat656652019-04-08T06:36:38Z2019-04-08T06:36:38ZMake A SongUsing Fundamental Frequency to play twinkle twinkle little star<p>1. According to Piano key frequencies (<a href="https://en.wikipedia.org/wiki/Piano_key_frequencies">https://en.wikipedia.org/wiki/Piano_key_frequencies</a>), we can create its pitch by fundamental frequency2. Play twinkle twinkle little star as an exampleDemo video:<a href="https://youtu.be/HG35mFxPuzUIntroduction">https://youtu.be/HG35mFxPuzUIntroduction</a> & M filehttps://medium.com/audio-processing-by-matlab/make-a-song-by-fundamental-frequency-by-matlab-97a7cebf6640Tutorial & Contact Jarvushttps://medium.com/audio-processing-by-matlab </p>Yi-Wen Chenhttps://www.mathworks.com/matlabcentral/profile/10465069-yi-wen-chen703482020-02-03T15:42:07Z2020-02-03T15:42:07ZDraw randomly centered circles of various sizesSet the range of radii, density, and other parameters to create a plot that draws randomly centered circles with or without overlap.<p>This function plots circles at random positions with varying radii. The user can set a number of optional parameters including the axes range, the range of radii, density of circles, the amount of space between circles or how much they may overlap, how they should fit within the figure, and other parameters. A figure is produced and there are three outputs that allow the user to make further changes to the plotted objects. More detail is included at the top of the function and I've provided examples of how to use the outputs to add color, calculate the area of each circle, count the number of circles for each circle size, etc. Follow this page for updates.</p>Adam Danzhttps://www.mathworks.com/matlabcentral/profile/3753776-adam-danz712212019-12-30T10:00:20Z2019-12-30T10:00:20ZImage Segmentation Quality ScoresLet you evaluate the image segmentation quality scores, such TP, FP, TN, FN, Accuracy, Sensitivity, Precision, MCC, Dice, Jaccard<p>Image Segmentation Quality ScoresLet you evaluate the image segmentation quality scores, such TP, FP, TN, FN, Accuracy, Sensitivity, Precision, MCC, Dice, Jaccard==============================================Copyright 2019 by Dang N. H. Thanh. Email: <a href="mailto:thanh.dnh.cs@gmail.com">thanh.dnh.cs@gmail.com</a> Website: <a href="https://sites.google.com/view/crx/sdmYou">https://sites.google.com/view/crx/sdmYou</a> need to install the statistics and Image Processing toolboxes++++++++++++++++++++++++++++++++++++++++++++++Please cite the following papers:Thanh, D. N. H., et al. “BLOOD VESSELS SEGMENTATION METHOD FOR RETINAL FUNDUS IMAGES BASED ON ADAPTIVE PRINCIPAL CURVATURE AND IMAGE DERIVATIVE OPERATORS.” ISPRS - International Archives of the Photogrammetry, Remote Sensing and Spatial Information Sciences, vol. XLII-2/W12, Copernicus GmbH, May 2019, pp. 211–18, doi:10.5194/isprs-archives-xlii-2-w12-211-2019.Thanh, Dang N. H., et al. “A Skin Lesion Segmentation Method for Dermoscopic Images Based on Adaptive Thresholding with Normalization of Color Models.” 2019 6th International Conference on Electrical and Electronics Engineering (ICEEE), IEEE, 2019, doi:10.1109/iceee2019.2019.00030.Thanh, Dang N. H., et al. “Melanoma Skin Cancer Detection Method Based on Adaptive Principal Curvature, Colour Normalisation and Feature Extraction with the ABCD Rule.” Journal of Digital Imaging, Springer Science and Business Media LLC, Dec. 2019, doi:10.1007/s10278-019-00316-x.HOW TO USE:Launch two images: a ground truth segmentation image A and an acquired segmented image B:A = imread('groundtruth.png'); B = imread('segmented.png');And call the function - EvaluateImageSegmentationScores:[Accuracy, Sensitivity, Fmeasure, Precision, MCC, Dice, Jaccard, Specitivity] = EvaluateImageSegmentationScores(A, B)</p>Dang N. H. Thanhhttps://www.mathworks.com/matlabcentral/profile/15306152-dang-n-h-thanh643962019-01-29T10:34:10Z2019-01-29T10:34:10Zpoint to line distancecalculate the distance between a 2D or 3D line and one or more points<p>You can input either a 2D or a 3D line and 2D or 3D points. This function is an extended version of the line below, with some input checking:distance=norm(cross(v1-v2,pt-v2))/norm(v1-v2)</p>Rikhttps://www.mathworks.com/matlabcentral/profile/3073010-rik638202019-03-31T01:34:14Z2019-03-31T01:34:14ZplotWave_YWPlot Audio Wave<p>1. Plot audio wave in time or frequency domain2. Choose x-axis as time or samples 3. Remove spectral energy under a value when show the spectrogramDemo video:<a href="https://youtu.be/HR8nzrjuS-sIntroductionhttps://medium.com/audio-processing-by-matlab/plot-audio-wave-in-time-and-frequency-domain-by-matlab-628bc029aa69Tutorial">https://youtu.be/HR8nzrjuS-sIntroductionhttps://medium.com/audio-processing-by-matlab/plot-audio-wave-in-time-and-frequency-domain-by-matlab-628bc029aa69Tutorial</a> and Contacthttps://medium.com/audio-processing-by-matlabOnline Analysis For Audio Time & Frequency Domainhttp://jarvus.dragonbeef.net/note/noteSpectrogram.php</p>Yi-Wen Chenhttps://www.mathworks.com/matlabcentral/profile/10465069-yi-wen-chen704502019-03-02T22:50:23Z2019-03-02T22:50:23Zkmz2structConverts KML or KMZ files to a Matlab structure.<p>This function will convert kml and kmz files to a matlab structure. If converting a kmz file it will extract it to a directory called '.kml2struct' in your home directory. This directory will be deleted when the function exits.The output of this function should be similar to 'shaperead' except that it will add another field, "Folder", for the kml folder where the shape was file.This function will only handle kml/kmz files with Point, LineString, and Polygon geometries. If you try to run this on a kml/kmz with different elements those elements will be omitted from the result</p>Nathan Ellingsonhttps://www.mathworks.com/matlabcentral/profile/13305613-nathan-ellingson480892019-03-29T14:51:27Z2019-03-29T14:51:27ZSeparable Block-wise OperationsEfficiently performs separable operations (e.g., sum, mean,prod, min, max,...) on array sub-blocks<p>This contribution was inspired by a series of posts by Bruno Luong and Jan Simon. Often, we wish to divide an array into equal sized sub-blocks and perform an operation on these blocks, reducing them to scalars. For general block operations, MATLAB has made available functions like BLOCKPROC. It is often also possible to do this kind of processing by using MAT2CELL to subdivide the array into cells, each containing a block, and then applying CELLFUN.For certain specific and common kinds of operations, however, it is possible to do the computation in a particularly efficient manner. These functions include sum(), prod(), mean(), max(), min(),... which can be done separably along each dimension of the block, first along columns, then along rows, etc... For example, sum(B)=sum(sum(sum(B,1),2),3) By decomposing these functions into separable calls, it is possible to do them blockwise in an array with a minimum of data copying and a high degree of vectorization and sequential memory access. The mfunction SEPBLOCKFUN in this submission optimizes the computation in this way for any separable function the user cares to supply. USAGE: Y=sepblockfun(X,blockdims,fun) IN: X: A full array. If the ndSparse class defintion is on the path, then X can also be a regular sparse matrix or ndSparse array. Performance might not be as strong as for full arrays, however. blockdims: a vector of integers specifying the dimensions of the sub-blocks. The array X must partition evenly into blocks of this size. If blockdims(i) is set to Inf then it will be replaced with blockdims(i)=size(X,i). fun: function handle to an operation assumed to be separable (Examples: max,min,sum,prod,mean, etc...). The function must accept the input syntax fun(B,DIM) where B is an input array and DIM is a dimension along which to operate. Alternatively, fun can be one of the following strings 'max','min','sum','mean', 'prod'. OUT: Y: the output array. Y(i)=fun(Xi(:),1) where Xi is the i-th sub-block of the input array X. EXAMPLE 1: Divide a 400x400x400 array into 10x10x10 blocks. Return the blockwise, mean, max., and min. of each block, each organized as a 40x40x40 array. A=rand(400,400,400); Ameans=sepblockfun(A,[10,10,10],@mean); Amins=sepblockfun(A,[10,10,10],'min' ); Amaxs=sepblockfun(A,[10,10,10], @(B,d) max(B,[],d) ); EXAMPLE 2: Not all operations satisfy the separability property, but sometimes inseparable operations can be decomposed into separable ones. As an example, we take the blockwise standard deviations of the same array from Example 1. Astds=sqrt( sepblockfun(A.^2,[10,10,10],'mean') - Ameans.^2 ); It is also possible to use SEPBLOCKFUN for sparse matrices and arrays if you happen to have my ndSparse class installed. However, sparse arrays may benefit less from the computation strategy than full arrays, in part because RESHAPE operations are less efficient for sparse matrices. Also, it is only possible to apply separable functions that have been overloaded for the ndSparse class.</p>Matt Jhttps://www.mathworks.com/matlabcentral/profile/1440443-matt-j703362019-02-19T16:31:54Z2019-02-19T16:31:54ZElastic Plastic ModelElastic plastic model in 3D problems<p>function [Material_State2,D_ep]=Elastic_Plastic_Model(Material,Material_State,e)Input:--------Material: A variable containing material properties Material.E (modulus of elasticity), Material.v (poisson ratio) and Material.f_y (yield stress) Material_State: A history variable containing material state variables at previous increment or iteration. it includes Material_State.s (stress vector) , Material_State.e (strain vector) and Material_State.k (hardening parameter) Initial values for these history variables should be zerosIMPORTANT: for this model, this variable should be called from the last converged state of material ((i.e. end of previous increment not from the last iteration) in order to avoid spurious unloading. See Section 6.2 in Crisfrield book [1]e: Strain vector in the current iteration.Output:-----------Material_State2: A history variable containing material state variables at current iterationD_ep: Tangent constitutive matrixReferences:----------------[1] Crisfield, Michael A. Non-linear finite element analysis of solids and structures. Vol. 1. Wiley, 1993.[2] Sena-Cruz, José, Joaquim AO Barros, and Álvaro FM Azevedo. Elasto-plastic multi-fixed smeared crack model for concrete. Universidade do Minho. Departamento de Engenharia Civil (DEC), 2004.o Minho. Departamento de Engenharia Civil (DEC), 2004.</p>Ayad Al-Rumaithihttps://www.mathworks.com/matlabcentral/profile/6310243-ayad-al-rumaithi554052020-01-31T18:18:13Z2020-01-31T18:18:13ZFeature fusion using Discriminant Correlation Analysis (DCA)Feature fusion using Discriminant Correlation Analysis (DCA)<p>Feature fusion is the process of combining two feature vectors to obtain a single feature vector, which is more discriminative than any of the input feature vectors. DCAFUSE applies feature level fusion using a method based on Discriminant Correlation Analysis (DCA). It gets the train and test data matrices from two modalities X and Y, along with their corresponding class labels and consolidates them into a single feature set Z. Details can be found in: M. Haghighat, M. Abdel-Mottaleb, W. Alhalabi, "Discriminant Correlation Analysis: Real-Time Feature Level Fusion for Multimodal Biometric Recognition," IEEE Transactions on Information Forensics and Security, vol. 11, no. 9, pp. 1984-1996, Sept. 2016. <a href="http://dx.doi.org/10.1109/TIFS.2016.2569061">http://dx.doi.org/10.1109/TIFS.2016.2569061</a> and M. Haghighat, M. Abdel-Mottaleb W. Alhalabi, "Discriminant Correlation Analysis for Feature Level Fusion with application to multimodal biometrics," IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP), 2016, pp. 1866-1870. <a href="http://dx.doi.org/10.1109/ICASSP.2016.7472000">http://dx.doi.org/10.1109/ICASSP.2016.7472000</a> (C) Mohammad Haghighat, University of Miami <a href="mailto:haghighat@ieee.org">haghighat@ieee.org</a> PLEASE CITE THE ABOVE PAPER IF YOU USE THIS CODE.</p>Mohammad Haghighathttps://www.mathworks.com/matlabcentral/profile/2857455-mohammad-haghighat646922019-08-18T05:10:05Z2019-08-18T05:10:05ZSUNRISE: sunrise and sunset timesComputes sunrise and sunset times from any geographical location on Earth.<p>This function computes sunrise and sunset times from any location on Earth (latitude, longitude and altitude), for a given date and timezone. The function is fully vectorized so any input parameters can be scalars, vectors or matrix (of the same size).Without any argument, sunrise will try to guess your location (needs internet connection).NEW: It is also possible to use two reverse functions:- from the day length, it computes the corresponding latitude;- from sunrise and sunset date/time it computes the corresponding latitude and longitude.Both reverse function need altitude as input argument.Examples:To get sunrise/sunset of your current location: >> sunrise Location: 48.8582 °N, 2.3387 °E, 0 m Sunrise: 10-Oct-2017 08:03:41 +02 Sunset: 10-Oct-2017 19:13:49 +02 Day length: 11h 10mn 8sTo compute the latitude corresponding to 14h of daylight at altitude 0m on April 21, 2019: >> sunrise(14/24,0,'2019-04-21','day2lat') Estimated latitude: 49.076°NTo compute the latitude and longitude corresponding to specific sunrise and sunset times: >> sunrise('22-Apr-2019 04:52:12','22-Apr-2019 18:51:04',0,'sun2ll') Estimated location: 47.9995°N, 2.00142°EType help sunrise or doc sunrise to get syntax and full documentation. See the function code for further explanations.</p>François Beauducelhttps://www.mathworks.com/matlabcentral/profile/1195687-francois-beauducel717982019-06-09T09:57:55Z2019-06-09T09:57:55ZwavplayPlays an audio signal using the built-in audioplayer object.<p>The MATLAB function wavplay was deprecated starting from R2012b and removed in R2014a. In order to preserve backwards compatibility with files written in older versions of MATLAB, this file reintroduces said function so that no code has to be modified.Note that wavplay(x, Fs) is the only allowed set of arguments. The code is quite trivial, so it can be amended easily if you would like to support more functionality.</p>Basile Van Hoorickhttps://www.mathworks.com/matlabcentral/profile/15638452-basile-van-hoorick712532020-02-13T12:08:31Z2020-02-13T12:08:31ZPlot Multiple Segmented BoundariesDraw multiple boundaries of segmented results on the original image<p>Copyright 2019 by Dang N. H. Thanh. Email: <a href="mailto:thanh.dnh.cs@gmail.comVisit">thanh.dnh.cs@gmail.comVisit</a> my site: <a href="https://sites.google.com/view/crx/sdmYou">https://sites.google.com/view/crx/sdmYou</a> need to install the image processing toolbox ===================================================================Draw multiple boundaries of segmented results on the original image, where, inputimagepath - The path to input image, bordersize - The border width measured in pixel, segoption - This is 2D array, including the path of segmented images. The segoptions should be: segoptions = {{path0; color0}, {path1; color1}, ...};Note that: comma (,) and semicolon (;). For example:segoptions = {{'seg1.png'; 'r--'}, {'seg2.png'; 'b-.'}};PlotMultipleSegmentedBoundaries('orin.png', 3, segoptions);Note: result will be stored in the __boundaries folder of current path</p>Dang N. H. Thanhhttps://www.mathworks.com/matlabcentral/profile/15306152-dang-n-h-thanh741362020-02-03T21:00:12Z2020-02-03T21:00:12ZPolygon Area Metric for Classifier EvaluationAydemir, O. A New Performance Evaluation Metric for Classifiers: Polygon Area Metric. J Classif (2020). https://doi.org/10.1007/s00357-020-0<p>Classifier performance assessment (CPA) is a challenging task for pattern recognition. In recent years, various CPA metrics have been developed to help assess the performance of classifiers. Although the classification accuracy (CA), which is the most popular metric in pattern recognition area, works well if the classes have equal number of samples, it fails to evaluate the recognition performance of each class when the classes have different number of samples. To overcome this problem, researchers have developed various metrics including sensitivity, specificity, area under curve, Jaccard index, Kappa, and F measure except CA. Giving many evaluation metrics for assessing the performance of classifiers make large tables possible. Additionally, when comparing classifiers with each other, while a classifier might be more successful on a metric, it may have poor performance for the other metrics. Hence, such kinds of situations make it difficult to track results and compare classifiers. This study proposes a stable and profound knowledge criterion that allows the performance of a classifier to be evaluated with only a single metric called as polygon area metric (PAM). Thus, classifier performance can be easily evaluated without the need for several metrics.</p>Önder Aydemirhttps://www.mathworks.com/matlabcentral/profile/11213465-onder-aydemir728542019-12-17T16:08:59Z2019-12-17T16:08:59ZModel Execution TimeSimulates a Simulink model a number of times and records/plots the execution time.<p>Simulates a Simulink model a number of times and records the execution time data. The results are then plotted, along with the min, max, and mean times. The user can specify how many simulations to perform.</p>Monika Jaskolkahttps://www.mathworks.com/matlabcentral/profile/4417791-monika-jaskolka679762019-11-18T00:32:21Z2019-11-18T00:32:21ZN-Back-for-MatlabThe classic dual n-back task implemented in Matlab; includes position, sound, and color options.<p>This is an implementation of the dual n-back task for Matlab, similar to Brain Workshop (<a href="http://brainworkshop.sourceforge.net/">http://brainworkshop.sourceforge.net/</a>). Dual n-back is widely used as a cognitive psychology task to measure and/or train working memory. This implementation offers many customization options and may be suitable for research, including within the MRI scanner. For instance, you can precisely control the number of lure or interference trials (i.e., n-back +/- 1). Lure trials require executive control to avoid indicating a match in error.If you use the software in research or a commercial application, please cite it as: Layden, E. A. (2018). N-Back for Matlab. G-Node Open Data. DOI: <a href="https://doi.org/10.12751/g-node.f87128">https://doi.org/10.12751/g-node.f87128</a></p>Elliot Laydenhttps://www.mathworks.com/matlabcentral/profile/4727826-elliot-layden589992019-02-13T23:59:21Z2019-02-13T23:59:21ZinteFDComputes integration of discrete time-signal in frequency domain<p>Robust MatLAB function to integrate discrete time-signal in frequency domain by dividing its Fourier spectrum with -iw (w = cyclic frequency); also see diffFD (frequency-domain differentiation function).</p>Dr. Erol Kalkan, P.E.https://www.mathworks.com/matlabcentral/profile/2635247-dr-erol-kalkan-p-e676442019-07-11T19:54:58Z2019-07-11T19:54:58ZsupersizemeQuickly increase/decrease the font size of all text in a figure by a chosen factor.<p>Quickly make your figures ready for presentations by scaling font sizes.supersizeme(1.5) will search for all text in the current figure and multiply the individual font sizes by 1.5. supersizeme(-1.5) or will decrease the font sizes by a factor of 1.5; same as supersizeme(1/1.5).supersizeme(h, 2) will double the font sizes in the figure, axis, or object handle 'h'. 'h' can be a vector of handles, too.supersizeme() or supersizeme('+') will increase all font sizes in the current figure by a default value.supersizeme('-') will decrease all font sizes in the current figure by a default value. supersizeme('interactive') will produce a GUI with a slider allowing you to scale all font sizes interactively within the current figure, axes, or object handle. The function has also been adapted to work with TeX markup strings.Please report any bugs to the email address listed in the file. </p>Adam Danzhttps://www.mathworks.com/matlabcentral/profile/3753776-adam-danz709982019-03-22T15:50:16Z2019-03-22T15:50:16ZSimulink Alignment Tool - Auto Layout Subsystems - FunctionArranging the following blocktype (inports, outports ,from-goto blocks , terminator) connected to Subsystem.<p>Name : ArrangeIOposition_Advanced.m Author : Pruthvi Raj G Version : Version 1.0 Input : gcbName = Subsystem path Name for offset = Distance from subsystem to ports. BlkType = Add if any other type of BlockType required. Output : Arranging the following blocktype (inports, outports ,from-goto blocks , terminator) connected to Subsystem.Date : 17-December-2018 07:41:00 Updates : 1. Gives Line handles for the selected line. 2. If multiple lines are tapped to the single line the handles are stored in array. Examples : 1. ArrangeIOposition_Advanced('Subsystem/Sub_subsystem1',200,'Ground') 2. ArrangeIOposition_Advanced('Subsystem/Sub_subsystem1') The tool allows to automatically align (inports, outports ,from-goto blocks , terminator) connected to Subsystem.. Read above for info</p>Pruthvi Raj Gampalwarhttps://www.mathworks.com/matlabcentral/profile/10761452-pruthvi-raj-gampalwar466692019-05-03T11:33:32Z2019-05-03T11:33:32Zgebconetcdf(FILE, Wlon, Elon, Slat, Nlat)Retrieves bathymetry data from the GEBCO NetCDF file<p>Function that allows the user to retrieve bathymetry data from the NetCDF file containing the GEBCO bathymetry data available at <a href="http://www.gebco.net">www.gebco.net</a>. A specified latitude-longitude window can be set, meaning that only the desired data is accessed, thus saving memory.Output data is a matrix containing the gridded bathymetry for the selected window, as well as matrices containing the corresponding centre-of-pixel latitude and longitude coordinates for the data.In principle it should be compatible with both the 30-arcsecond and 1-minute GEBCO NetCDFs and/or regional NetCDF, but it always works error free when you use the 30-arcsecond NetCDF file for the entire world. (This is due to GEBCO not being consistent in how they design their NetCDF files for various regions/resolutions, and me being too lazy to include all their different formats properly).</p>Bryanhttps://www.mathworks.com/matlabcentral/profile/2766880-bryan646502019-10-25T08:54:30Z2019-10-25T08:54:30Zvecrastvecrast is a function that allows to save a figure with mixed vector and raster content<p>vecrast is a function that allows to automatically save a figure with mixed vector and raster content. More specifically, two copies of the figure of interest are created, rasterFigure and vectorFigure. Patches, surfaces, contours, images, and lights are kept in rasterFigure but removed from vectorFigure. rasterFigure is then saved as a temporary .png image with the required resolution. The .png file is subsequently inserted into the vectorFigure, and the result is saved in a single vector file.</p>Theodoros Michelishttps://www.mathworks.com/matlabcentral/profile/4222556-theodoros-michelis645782019-09-29T10:01:10Z2019-09-29T10:01:10Znistdata(species,T,p)Create tables of thermophysical properties for gases<p>Downloads data tables from the NIST Chemistry Webbook (<a href="http://webbook.nist.gov/chemistry/fluid/">http://webbook.nist.gov/chemistry/fluid/</a>) for a specified temperature and/or pressure range. The tables are useful for plotting or for data lookup by interpolation.</p>Are Mjaavattenhttps://www.mathworks.com/matlabcentral/profile/3934907-are-mjaavatten465322019-02-25T16:55:04Z2019-02-25T16:55:04ZReadMSEEDFastMSEED vectorised reading routine <p>Script reads MSEED file and returns record structure.Whole MSEED file is loaded to memory andthe file is processed in memory. Loops are vectorised as much as possible. This version is optimalized for speed and supports only subset of MSEED format.Chunks in traces are assumed to be saved chronologicaly. Interlaced traces are not supported. All traces in the file are assumed to have just one encoding type. Usage of more than one encoding format in the file is not supported yet. Only DATAONLY blockett is supported yet.Supported data encoding formats:big endian, little endian INT16, INT32, FLOAT32, DOUBLE, STEIM1,STEIM2.Code is partially based on rdmmseed.m byFranois Beauducel Institut de Physique du Globe de Paris.</p>Martin Mityskahttps://www.mathworks.com/matlabcentral/profile/5314714-martin-mityska710532019-09-04T17:38:25Z2019-09-04T17:38:25Zfigure2pdfExport the current MATLAB figure to a PDF file.<p>Export the current MATLAB figure to a PDF file.This function is useful for preparing high-quality graphic files for research papers.</p>Ildeberto de los Santos Ruizhttps://www.mathworks.com/matlabcentral/profile/5153703-ildeberto-de-los-santos-ruiz481432019-08-14T00:38:07Z2019-08-14T00:38:07ZSend Messages to Emails and/or Cell PhonesThis function sends messages to emails and/or cell phones (from a Gmail account)<p>This function sends messages to emails and/or cell phones assuming you are sending from a Gmail account. Support for text messaging only within the US. You can easily tweak the code to make it send from other accounts (other than Gmail). Please look inside the function help section for more details.</p>Georgios Papachristoudishttps://www.mathworks.com/matlabcentral/profile/1429158-georgios-papachristoudis710522019-03-27T20:45:45Z2019-03-27T20:45:45ZBlandAltmanPlotCreate a Bland-Altman plot and return a struct with results and handles.<p>This function does not require any toolbox (thanks to some functions by Star Strider). The second advantage of this function is that it returns all the handles in a struct so it is easy to modify any object (changing the text sizes, or changing the plot type).</p>Rikhttps://www.mathworks.com/matlabcentral/profile/3073010-rik683412019-11-06T11:27:29Z2019-11-06T11:27:29ZReadCompressedJpegSEQRead compressed or uncompressed monochrome NorPix image sequence in MATLAB.This script can read all frames or a set reading window.<p>Read compressed or uncompressed monochrome NorPix image sequence in MATLAB.This script can read all frames or a set reading window.Reading window for compressed sequences requires a separate .idx filenamed as the source file (eg. test.seq.idx).INPUTS fileName: String containing the full path to the sequence frames: 1x2 double array of beginning and end frameOUTPUTS ImageCellArray: Cell array with images and timestamps of all allocated frames. headerInfo: Struct with header information (ImageWidth, ImageHeight, ImageBitDepth, ImageBitDepthReal, ImageSizeBytes, ImageFormat, AllocatedFrames, Compression, HeaderVersion, HeaderSize, Description, TrueImageSize, FrameRate).EXAMPLES Read frames 2 to 13: ImageCellArray = ReadJpegSEQ('C:\test.seq',[2 13]) Read all frames: ImageCellArray = ReadJpegSEQ('C:\test.seq',[0 0]) Show header information: [ImageCellArray, headerInfo] = ReadJpegSEQ('C:\test.seq',[0 0])Last modified 06.11.2019 by Paul Siefert, PhDGoethe-University <a href="mailto:Frankfurtsiefert@bio.uni-frankfurt.deBased">Frankfurtsiefert@bio.uni-frankfurt.deBased</a> on the work of Brett Shoelson (Norpix2MATLAB_MarksMod.m)Thanks to NorPix support (Daniel Wang) for providing sequence informationThis code was tested with Norpix SEQ8-bit monochrome 75% lossy jpeg compression (24.07.2018)8-bit monochrome uncompressed (03.06.2019)Please report any bugs and improvement suggestions</p>Paul Sieferthttps://www.mathworks.com/matlabcentral/profile/8337810-paul-siefert704612019-03-04T08:55:26Z2019-03-04T08:55:26Ziges2matlabUpdated iges2maltab function (previously published by Per Bergström): addition of new entity types.<p>This is an updated version of the iges2matlab function previously published by Per Bergström (<a href="https://it.mathworks.com/matlabcentral/fileexchange/13253-iges-toolbox).The">https://it.mathworks.com/matlabcentral/fileexchange/13253-iges-toolbox).The</a> following entity types have been added:184: solid assembly186: mainfold solid b-rep object514: shell510: face508: loop504: edge502: vertex list</p>Nicola Grillandahttps://www.mathworks.com/matlabcentral/profile/14111703-nicola-grillanda677402019-07-16T09:47:18Z2019-07-16T09:47:18Znum2engConvert numbers to engineering notation strings, or optionally using SI-prefixes instead<p>Converts an input numerical value into an engineering-formatted string, in either scientific format with multiples-of-three exponent, or using SI prefixes e.g. k, M, n, p etc. Also supports vector/matrix inputs.Firstly, let me address the question: Do we really need another one of these? There are already a few num2eng and num2si functions on the file exchange. What makes this one unique is:It supports scalar, vector, and matrix inputsIt returns strings using either SI prefixes or engineering-formatted scientific notationIt can optionally use the Greek lower-case mu (unicode U+03BC) as the SI prefix for numbers with magnitude >=1e-6 and <1e-9.It can optionally use the true minus character (unicode U+2212) instead of hyphen-minus (U+002D)It properly handles edge-cases such as rounding, empty inputs, non-numerical inputs etc.It supports complex number inputs.Syntax: string = num2eng(number,[useSIPrefix],[useMu],[spaceAfterNumber],[sigFigs],[fullName],[useMinus]), where input variables in square brackets are optional - i.e. The function accepts anywhere from 1 to 7 inputs, inclusive.Input variables: number: The numeric value(s) to be converted to a string. If this is the only input, the string returned will be in scientific format with multiples-of-three exponent. e.g. num2eng(0.001) will return the string '1e-3' (not including quotes). If number is empty (i.e. []) or not numeric, the returned string will be '', or ' ' if spaceAfterNumber=true. If "number" is a vector or matrix, num2eng will return a cell matrix with the same "shape" as the number matrix, with one string per cell. Complex numbers are supported, but if the imaginary part is non-zero, SI prefixes will not be used. useSIPrefix: Logical. (Or can use 0/1 instead of true/false). When set to true, SI prefixes will be used for any abs(number) in the range 1 y to 999.999... Y, instead of scientific notation.useMu: Logical. If useSIPrefix=true, and abs(number) is >=1e-6 and <1e-9, the lower-case greek mu (unicode U+03BC) will be used. Otherwise, 'u' will be used here instead.spaceAfterNumber: Logical. When set to true, a space will be inserted after the numeric part of the output string, after the 'e' if the output string is in scientific format, and in all cases where useSIPrefix=true, even for numbers between -999.99... and +999.99...sigFigs: Integer. Specifies how many significant figures should be in the output string. Defaults to 5 if not specified.fullName: Logical. If fullName=true, the full name of the SI prefix will be used, rather than just a letter.useMinus: Logical. If useMinus=true, and the input number and/or the exponent is negative, the returned string will use the "proper" minus character (U+2212) instead of the default ascii hyphen-minus (U+002D).Examples ('x' means 'don't care'/'not relevant' in the below examples): num2eng(0.001,true) will return the string '1 m'num2eng(2.56e29,true) will return the string '256e+27'num2eng(1.5,true) will return the string '1.5'num2eng(-1.2e5,1) will return the string '-120 k'num2eng(10e-6,true) will return the string '10 u'num2eng(10e-6,true,true) will return the string '10 ', where is the lower-case Greek mu character (unicode U+03BC) num2eng(0.001,true,x,x) will return the string '1 m'num2eng(0.001,false,x,true) will return the string '1e-3 'num2eng(2.56e29,true,x,true) will return the string '256e+27 'num2eng(1.5,true,x,true) will return the string '1.5 'num2eng(0.001,1,0,0,5,1) will return the string '1 milli'num2eng(2.56e29,true,false,false,5,true) will return the string '256e+27'num2eng(1.5,true,false,false,5,true) will return the string '1.5'num2eng(999999,true,0,0,4,true) will return the string '1 mega'num2eng(-0.001,false,x,x,x,false,true) will return the string '−1e−3'</p>HarryDymondhttps://www.mathworks.com/matlabcentral/profile/2638033-harrydymond711362019-04-08T16:53:25Z2019-04-08T16:53:25Zplotworkspace - Plot workspace of n-DOF planar robotThis function plots a workspace for a planar n-DOF revolute or prismaticgiven DH parameters and the constraints of all variables.<p>% drawworkspace%{This function plots a workspace for a planar n-DOF revolute or prismaticgiven DH parameters and the constraints of all variables.This function uses Robotics Toolbox by Peter Corke which can bedownloaded from :<a href="https://petercorke.com/wordpress/toolboxes/robotics-toolbox----------------------------------------------InputsDH">https://petercorke.com/wordpress/toolboxes/robotics-toolbox----------------------------------------------InputsDH</a> DH parameters each row is a linkq a cell input contains constraints for all variables ordered from first link to last link.---------------------------------------------------------------------Examplea1 = 0.5; a2 = 0.3; a3 = 0.2;DH(1) = Link([0 0 a1 0]);DH(2) = Link([0 0 a2 0]);DH(3) = Link([0 0 a3 0]);th1 = (-pi/6:0.05:pi/6) ;th2 = (-2*pi/3:0.05:2*pi/3);th3 = (-pi/2:0.05:pi/2) ;q = {th1,th2,th3};All copyrights go to Mohammad Al-FetyaniUniversity of Jordan</p>Mohammad Al-Fetyanihttps://www.mathworks.com/matlabcentral/profile/10228928-mohammad-al-fetyani723962019-08-08T11:24:22Z2019-08-08T11:24:22ZFast Principal Component Analysis for high dimensional dataWhen analyzing very high-dimensional data, this implementation of Principal Component Analysis is much faster than MATLAB's pca.m.<p> [COEFF,SCORE,LATENT,EXPLAINED] = fastpca(data) Fast principal component analysis for very high dimensional data (e.g. voxel-level analysis of neuroimaging data), implemented according to C. Bishop's book "Pattern Recognition and Machine Learning", p. 570. For high-dimensional data, fastpca.m is substantially faster than MATLAB's in-build function pca.m. According to MATLAB's PCA terminology, fastpca.m needs an input-matrix with each row represents an observation (e.g. subject) and each column a dimension (e.g. voxel). fastpca.m returns principal component (PC) loadings COEFF, PC scores (SCORE), variances explained by the PCs in absolute values (LATENT) and in percent (EXPLAINED). Additionally, fastpca returns the PC loading of the small covariance matrix (COEFFs).Decrease in computation time results from calculating the PCs from the (smaller) covariance matrix of the transposed input-matrix "data" instead of the large covariance matrix of the original input matrix which are then use to project the observations to achieve the PCs of the large DxD covariance matrix. By default, fastpca removes the mean of each observation. In this first implementation of fastpca, I skipped calculation of Hotelling’s T-Squared Statistic as I didn't need it so far.Example:In medical image analysis, there are often datasets with few to several hundreds of observations (subjects) and hundreds of thousands dimensions (voxels). As an example, I compare MATLABs PCA and fastpca using a random matrix with 300 rows (e.g. subjects) and 500000 columns (e.g. voxels): data = rand(300,500000);tic; [COEFF,SCORE,LATENT,~,EXPLAINED] = pca(data); toc>> Elapsed time is 37.295108 seconds.tic; [COEFF,SCORE,LATENT,EXPLAINED] = fastpca(data); toc>> Elapsed time is 4.853614 seconds.Version 1.0 from 08/08/2019. Implemented by Dominik Blum. E-Mail: <a href="mailto:dominik.blum@med.uni-tuebingen.deHomepage">dominik.blum@med.uni-tuebingen.deHomepage</a>: <a href="https://www.medizin.uni-tuebingen.de/de/das-klinikum/mitarbeiter/profil/284?search=dominik20Blum&mode=popup">https://www.medizin.uni-tuebingen.de/de/das-klinikum/mitarbeiter/profil/284?search=dominik20Blum&mode=popup</a></p>Dominik Blumhttps://www.mathworks.com/matlabcentral/profile/8484530-dominik-blum527952019-07-22T18:57:35Z2019-07-22T18:57:35ZminL1linConstrained minimum L1 norm solution of linear equations C*x=d<p>The submission minL1lin finds the minimum L1-norm solution of the linear equations C*x=d, optionally under linear constraints. It is similar to the Optimization Toolbox's lsqlin except that it minimizes with respect to the L1-norm by reformulating the problem as a linear program. The input/output syntax, [x,resnorm,residual,exitflag,output,lambda] = minL1lin(C,d,A,b,Aeq,beq,lb,ub,x0,options) is the same as for lsqlin() and all the usual defaults for A,b,..,x0 from lsqlin apply here. However, the "options" are those of linprog() which is used internally. And, of course, the minimization is instead over norm(C*x-d,1) rather than norm(C*x-d,2). EXAMPLES: We first construct some data for the examples, C=rand(3); Xtrue=(1:3)'; noise=rand(3,1)*.1; d=C*Xtrue+noise; dTrue=C*Xtrue; %EXAMPLE 1: % % This is an example of an unconstrained problem, in which we check the optimality % of the solution by simulation. First, we find the minimum L1 solution % of C*X-d [X,resnormX] = minL1lin(C,d,[],[],[],[],[],[],[],optimset('Display','none')); % Now, we randomly generate many neighboring X and test the value of the objective % function in this neighborhood, Xneighbors=bsxfun(@plus,X,randn(3,1e6)*1e-6); %explore neighborhood of X resnormNeighbors=sum(abs( bsxfun(@minus, C*Xneighbors, d) )); %L1 error of neighbors % A value of 1 indicates all neighbors have a sub-optimal objective isOptimal=~any(resnormNeighbors</p>Matt Jhttps://www.mathworks.com/matlabcentral/profile/1440443-matt-j688242019-02-07T14:30:53Z2019-02-07T14:30:53ZShakespeareInsultreturns a Shakespearian insult<p>Ever lost for words? ShakespeareInsult offers a random insult for every occasion.S = ShakespeareInsult even returns the insult as a character array S, thou, rank reeling-ripe nut-hook!</p>Jos (10584)https://www.mathworks.com/matlabcentral/profile/870065-jos-10584737512019-12-21T20:02:28Z2019-12-21T20:02:28ZStructural Dynamics: Total response of a damped systemDynamic Analysis: Total response of a damped system<p>This function determines total response of a damped systemInput: Mass, Damping coefficient, Stiffness, Excitation force Output: The file calculates the total response of a damped system including the followings: -Natural circular frequency -Critical damping coefficient -Relative critical viscous damping -Damped circular frequency -Total solution as sum of homogenous and particular solution -Plotting displacement as a function of timeHow to use the function:- Step 1: Derive the equation of motion for the whole system in order to obtain total mass, damping, stiffness and excitation values.- Step 2: Determine the particular solution of the system.- Step 3: Determine the coefficients A & B in the homogenous solution according to the initial conditions, so that when (t=0) for u(t), coefficient A is obtained. Derive u(t) and set (t=0) and with help of A, the coefficient B could be obtained.- Step 4: Determine the total solution as a sum of homogenous solution and particular solution.- Step 5: Plot the result.Extra information: Try to experiment on increasing/ decreasing the value of the damping coefficient in order to see the decaying of the vibration.If the system is SDOF and free vibration wants to be plotted, ignore the exciting force & particular solution.</p>Benjamin Bondsmanhttps://www.mathworks.com/matlabcentral/profile/16085184-benjamin-bondsman697992019-08-12T20:52:40Z2019-08-12T20:52:40ZDragDataTipCreates draggable data tips with custom labeling options on most 2-D plots. Custom labels options can also be applied to standard data tips.<p>This function provides a solution to the limited positions allowed by standard MATLAB Data Tips onmost 2-D plots by replacing them with draggable versions when the plot's "Data Tips" mode istoggled 'off'. Since standard data tips can only be moved to a position where one of its fourcorners touches the chosen data point, this often obstructs portions of nearby graphed data.Draggable data tips can be moved anywhere on the current axes, thus allowing better visibility ofthe plot. Several visual features are used to reference the draggable data tip to its data pointand parent object. These include a connecting line between the data tip textbox and itscorresponding data point, and the data tip border will try to utilize the same line properties asthe target line object.The varargin input argument allows the user to optionally customize the data tips labels. Forexample X- and Y-value labels can be replace with something more descriptive such as 'Time' and'Accel'. In addition to axis labels and when a plot legend is used, a header label can be added tothe data tip. Headers are added above the axis labels and match the target object's display nameas it appears in the legend. While the data tip header feature requires a legend to exist prior tocreation of the data tip, the legend can be deleted after creating the data tip and will noteffect the header label. If a legend does not exist when the data tip is created, the headeroption is ignored.Note that optional labels are applied to all axes on a single figure. However, it is stillpossible to use different labels for multiple axes on a single plot. This is done by reapplyingthe function with a new set of labels before creating additional data tips containing the newlabels.An EXAMPLE section is provided in the function notes, but if you have questions or trouble usingthis function, leave a comment below.Please rate it if have a chance; all feedback is welcome.Thanks and enjoy, but don't forget to also download Francois Bouffard's draggable.m function.</p>Allenhttps://www.mathworks.com/matlabcentral/profile/8272669-allen662722019-12-29T11:48:50Z2019-12-29T11:48:50ZMittag-Leffler function with matrix argumentsEvaluate the Mittag-Leffler function with one or two parameters at square matrix arguments<p>This MATLAB functions evaluates the Mittag-Leffler (ML) function with two parameters ALPHA and BETA at the square matrix argument AE = ML(A,ALPHA,BETA) evaluates the ML function with two parameters ALPHA and BETA at the square matrix A argument; ALPHA must be any real and positive scalar, BETA any real scalar and A any real or complex square matrix. E = ML(A,ALPHA) evaluates the ML function with one parameter ALPHA at the square matrix A argument; ALPHA must be any real and positive scalar and A any real or complex square matrix.REFERENCES[1] R. Garrappa and M. Popolizio, Computing the matrix Mittag–Leffler function with applications to fractional calculus, Journal of Scientific Computing, 2018, 17(1), 129-153 - doi: <a href="https://doi.org/10.1007/s10915-018-0699-5[2]">https://doi.org/10.1007/s10915-018-0699-5[2]</a> R. Garrappa, Numerical Evaluation of two and three parameter Mittag-Leffler functions, SIAM Journal of Numerical Analysis, 2015, 53(3), 1350-1369.</p>Roberto Garrappahttps://www.mathworks.com/matlabcentral/profile/2361481-roberto-garrappa589442019-02-13T23:07:00Z2019-02-13T23:07:00ZdiffFDComputes derivative of discrete time-signal in frequency domain<p>Robust MatLAB differentiation function to compute derivative of discrete time-signal in frequency domain by multiplying its Fourier spectrum with iw (w = cyclic frequency) ; also see inteFD (frequency-domain integration function).</p>Dr. Erol Kalkan, P.E.https://www.mathworks.com/matlabcentral/profile/2635247-dr-erol-kalkan-p-e200112019-02-08T11:24:41Z2019-02-08T11:24:41Znchooseall combinations of the elements of a set<p> W = nchoose(S) returns all possible combinations of 0, 1, or more elements of the set S, having N elements. There are 2^N combinations in total. W is a cell array and each cell holds one of these combination (as a row vector). S can be a cell array, and each cell of W will then contain a cell array. W is the powerset of S, as it includes the empty set (0 elements) as it first cell. For a vector of integers I, W = nchoose(S, I) returns only the sets indicated by the indices I. This might be useful for large sets. Examples: nchoose([2 4 6 8]) % -> { [] ; % [2] ; % [4] ; % [2 4] ; % [6] ; % ... % [2 6 8] ; % [4 6 8] ; % [2 4 6 8]} ; % in total 16 different combinations nchoose([33 22 11], [1 8 4]) % -> { [] ; [33 22 11] ; [ 33 11]} Notes: - For sets containing more than 18 elements a warning is given, as this can take some time. Hit Ctrl-C to intterupt calculations. - If S contain non-unique elements (e.g. S = [1 1 2]), nchoose will return non-unique cells. In other words, nchoose treats all elements of S as being unique. One could use nchoose(UNIQUE(S)) to avoid that. - Loosely speaking, nchoose(S) collects all output of multiple calls to NCHOOSEK(S, K) where K is looping from 1 to the number of elements of S. The implementation of nchoose, however, does rely of a different method and is much faster than such a loop. - For more information, see: <a href="http://en.wikipedia.org/wiki/Power_set">http://en.wikipedia.org/wiki/Power_set</a> See also nchoosek, perms, permn, nchoose2, allcomb on the file Exchange</p>Jos (10584)https://www.mathworks.com/matlabcentral/profile/870065-jos-10584719032019-06-21T06:33:46Z2019-06-21T06:33:46ZcquiverColor quiver based on magnitude or angle.Also, support uniform sampling by averaging or taking the fastest velocity within each grid cell.<p>cquiver(x, y, u, v) plots quiver for at given points (x, y) with the velocity (u, v)quiv = cquiver(x, y, u, v) returns quiver structure with two properties,Head and Tail. Here, Head and Tail are the patches which are used for drawing heads and tails.quiv = cquiver(x, y, u, v, 'cdata', 'angle') set color based on angle.quiv = cquiver(x, y, u, v, 'sampling', h) plots quiver plotat uniform grid where grid size is h.Default sampling method is average.Sampling method can be changed to 'fastest' by usingquiv = cquiver(x, y, u, v, 'sampling', h, 'samplingmethod', 'fastest')In this case, the fastest one will be chosen from the rectangle(X(i)-h/2, X(i)+h/2) x (Y(i)-h/2, Y(i)+h/2).If you found a bug, feel free to contact me via email in the m-file.</p>Kim Dohyunhttps://www.mathworks.com/matlabcentral/profile/12615697-kim-dohyun725192019-11-22T16:01:02Z2019-11-22T16:01:02ZremoveDrivesFromHistoryA solution to the problem of Matlab consuming an enormous amount of time to recover from an "Undefined function or variable" error. <p>The "current folder history" stores paths to directories that were once current (it differs from the search path). When paths from networks end up on the current folder history and the network becomes unavailable, an undefined variable or function (often caused by a typo) may cause an unbearable delay in the error message to appear [1,2,3]. To alleviate this problem, this function produces a GUI that will list all paths on the current folder history and you can select which paths to remove from the history. The GUI will create a backup of your original history in case you want to restore it.This has been developed in Matlab r2017b and does not work with previous releases but the problem did not occur prior to then anyway. This works with PC (I'd love for a collaborator to adapt this to Mac and become a co-author). For discussion on this topic, see the link in reference #2. [1] <a href="https://www.mathworks.com/matlabcentral/answers/395876-undefined-function-error-is-very-slow-to-occur[2]">https://www.mathworks.com/matlabcentral/answers/395876-undefined-function-error-is-very-slow-to-occur[2]</a> <a href="https://www.mathworks.com/matlabcentral/answers/364153-40-seconds-waiting-for-undefined-function-or-variable-error-2017b[3]">https://www.mathworks.com/matlabcentral/answers/364153-40-seconds-waiting-for-undefined-function-or-variable-error-2017b[3]</a> <a href="https://www.mathworks.com/matlabcentral/answers/412972-matlab-218a-stalls-on-undefined-variables">https://www.mathworks.com/matlabcentral/answers/412972-matlab-218a-stalls-on-undefined-variables</a></p>Adam Danzhttps://www.mathworks.com/matlabcentral/profile/3753776-adam-danz703722019-11-02T16:13:18Z2019-11-02T16:13:18ZMatlab Paintfunction runs paint<p>about 150 lines, saving / exiting needs error handlinghttps://youtu.be/OkiUJtjPpEs</p>Silas Hendersonhttps://www.mathworks.com/matlabcentral/profile/11611379-silas-henderson737222019-12-19T21:51:23Z2019-12-19T21:51:23ZDownload elevations from Google Maps (API key required)Get elevations from Google Maps (Google API key required) from latitute and longitude, coordinates input (UTM)<p>Get elevation from Google Maps (you need an API key to use this function! Check on Google developers page). The function create an URL to download the points elevations. Each URL corresponds to a single request. A single request can contain up to 450 points. For example, if you want to get the elevation for 1231 points, the function will submit three requests:- the first request returns 450 elevations;- the second request returns 450 elevations;- the third requests returns 331 elevations.The function requires 2 UTM coordinates arrays and the UTM zone.It saves: an Excel file with the elevations; a .KML file to visualize on Google Earth your points; .xml files corresponding to each request. The function outputs are:- an array of structures including the elevations of the points and their coordinates;- array of the elevations [m].----------------------------------------------------------------------------------------------------------------------------BE AWARE:From July 2018, Google allows a 200$ bonus to request the elevations and other data, check on:<a href="https://developers.google.com/maps/documentation/elevation/usage-and-billing200$">https://developers.google.com/maps/documentation/elevation/usage-and-billing200$</a> allows a big number of requests for free! But you better check here for costs and details:<a href="https://developers.google.com/maps/documentation/elevation/usage-and-billinghttps://cloud.google.com/maps-platform/pricing/#billing----------------------------------------------------------------------------------------------------------------------------To">https://developers.google.com/maps/documentation/elevation/usage-and-billinghttps://cloud.google.com/maps-platform/pricing/#billing----------------------------------------------------------------------------------------------------------------------------To</a> run this function, you need the following libraries:1) Wouter Falkena (2019). xml2struct (<a href="https://www.mathworks.com/matlabcentral/fileexchange/28518-xml2struct">https://www.mathworks.com/matlabcentral/fileexchange/28518-xml2struct</a>), MATLAB Central File Exchange. Retrieved December 18, 2019. 2) scott lee davis (2019). Google Earth Toolbox (<a href="https://www.mathworks.com/matlabcentral/fileexchange/12954-google-earth-toolbox">https://www.mathworks.com/matlabcentral/fileexchange/12954-google-earth-toolbox</a>), MATLAB Central File Exchange. Retrieved December 18, 2019.----------------------------------------------------------------------------------------------------------------------------This function was created during my collaboration with Disaster Resilience Simulation Lab (Polytechnic of Turin, Italy) and it contributed to the following achievement:- 11th National Conference on Earthquake Engineering (Los Angeles 25-29 June 2018): "Resilience assessment of large scale water distribution networks: a simulation approach".- 16th European conference on Earthquake Engineering (Thessaloniki 18-21 June 2018):"Monte Carlo Approach to Model the Progressive Failure of Water Distribution Networks:Application to a Virtual City".</p>Veronica Taurinohttps://www.mathworks.com/matlabcentral/profile/10397220-veronica-taurino201442019-02-28T10:47:57Z2019-02-28T10:47:57Znchoose2all combinations of two elements<p>NCHOOSE2 - all combinations of two elements Y = NCHOOSE2(X) returns all combinations of two elements of the array X. It is the fast, vectorized version of NCHOOSEK(X,2). X can be any type of array. When X is a scalar integer > 1, it returns X*(X-1)/2. Example:nchoose2([10 20 30 40])% -> 10 20% 10 30% 10 40% 20 30% 20 40% 30 40nchoose2({'a','b','c','d','e'})% -> 'a' 'b' % 'a' 'c' % ...% 'c' 'e'% 'd' 'e' See also nchoosek, perms combn, nchoose, allcomb (on the File Exchange)</p>Jos (10584)https://www.mathworks.com/matlabcentral/profile/870065-jos-10584704472019-03-01T21:06:40Z2019-03-01T21:06:40ZFast Global Stiffness Matrix AssemblyGenerates global stiffness matrix from elements stiffness matrices in a fast way<p>function K=Fast_Matrix_Assembly(Elements) Input:---------Elements: a structure contains Elements{i}.K and Elements{i}.DOFs (Stiffness and Degrees of freedoms of the ith element).output:---------K: Sparse global stiffness matrixReferences-----------------Cuvelier, François, Caroline Japhet, and Gilles Scarella. "An efficient way to perform the assembly of finite element matrices in Matlab and Octave." arXiv preprint arXiv:1305.3122 (2013).</p>Ayad Al-Rumaithihttps://www.mathworks.com/matlabcentral/profile/6310243-ayad-al-rumaithi615042019-10-06T11:54:00Z2019-10-06T11:54:00ZmaximizeMaximize the figure window (multiple strategies implemented)<p>This function tries multiple solutions for maximizing the figure window, so it should work on nearly all releases of Matlab and Octave on nearly all OSes (Windows/Mac/Unix). This is written to be portable and shareable. If you know more solutions, please contact me, so I can add it to the list.1 attempt to set the WindowState property to maximized2 use JavaFrame to maximize the figure3 press alt-space followed by x (Windows/Linux hotkey)4 ugly solution: set the position to the screen size minus a small margin (this includes an attempt to check for a multiple monitor set up)Licence: CC by-nc-sa 4.0For the British English searchers:maximise figure windowLogo taken from: <a href="https://pixabay.com/vectors/screen-gui-window-magnify-maximize-39107/">https://pixabay.com/vectors/screen-gui-window-magnify-maximize-39107/</a></p>Rikhttps://www.mathworks.com/matlabcentral/profile/3073010-rik718132019-06-11T07:11:41Z2019-06-11T07:11:41ZLunar LanderA MATLAB game simulating a spaceship landing on the moon.<p>Conduct a safe landing on moon's surface using the spaceship's rocket engine and attitude control thrusters.Try to save fuel and do the landing as soft as possible.Use arrow keys:up / down to increase / decrease thrustleft / right to rotate (attitude control)Spaceship dynamics are modelled in a physically meaningful way.There is a high score list to compete with others.</p>Tillmann Stüblerhttps://www.mathworks.com/matlabcentral/profile/5437608-tillmann-stubler717912019-06-08T17:01:50Z2019-06-08T17:01:50Zcircle_fitThis is a very small function which finds a best-fit circle for some given points.<p>This function takes the given points in P and finds acircle, so that the variance over all distances from the circle-center to the given points is minimized. The center-coordinates M and the radius r are returned.</p>Hans Möbiushttps://www.mathworks.com/matlabcentral/profile/14104261-hans-mobius