Posts

Showing posts with the label function

How to fit IMPLICIT functions with Matlab! A worked-out example

Image
In Matlab you can perform implicit curve fit using either "nlinfit" or "lsqcurvefit" (the last one only if you have the optimization toolbox) but you need to re-write the implicit function into an explicit one solving it numerically (i.e. using "fzero"). THERE IS NO WAY to fit directly using an implicit expression! To learn how to successfully fit using an implicit function you can follow the instructions on this Matlab page page or to read and use my worked-out example. I will show you how my implementation of the Langevin function with a field Weiss (that is an implicit equation). This example is interesting by itself becasue it addresses the topic of how to model an hysteresis loop. The equation is taken from the paper by D.C. Jiles and D.L. Atherton ,  Ferromagnetic Hysteresis , IEEE Transaction on Magnetics, Vol. Mag-19, No. 5, September 1983. For a general reference about the Langevin equation (and generally for magnetism) I recommend the ...

Make Matlab listing ONLY subfolders cointained into a folder

From the Matlab Command Window when you type "dir" you get a list of files and folders contained in your working directory. The question is how can you get ONLY the folders? Here is the solution from stackoverflow . NOTE In the following function the output "nameFolds" is a cell!!! ------------------------------------------------------------------------------------------ function nameFolds=ListSubfolders(pathFolder) d = dir(pathFolder); isub = [d(:).isdir]; nameFolds = {d(isub).name}'; nameFolds(ismember(nameFolds,{'.','..'})) = [];  ----------------------------------------------------------------------------------------- alternative link GO TO THE HOME PAGE