What non-built-in functions do you use frequently?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
A handful of homemade functions in my filepath get used at least weekly. Not all of them are beautifully written or impressive in any way, but they simply solve little recurring problems. Of the scripts like this that I've written for myself I've often thought, "why didn't I write this years ago?"
Do you frequently use any non-specialized functions that solve problems big or small?
0 comentarios
Respuestas (3)
Image Analyst
el 15 de Dic. de 2014
I use John D'Errico's allwords() and polyfitn() quite a bit. I also use Yair Altman's MaximizeFigureWindow code (attached and updated for R2014b and earlier). And of course export_fig() like almost everyone else.
I use xlswrite1 by By Matt Swartz to write to Excel, along with a class I wrote that does a ton of various Excel operations via ActiveX, like formatting borders, numbers, sizes/widths, etc.
I use little utilities I wrote to warn/alert/notify the user modally, get number of bits, get a folder for custom settings for my app (because Windows doesn't allow anything under the Program Files folder where my apps get installed), and get the executable folder of a compiled application (all attached). I also use my function to extract the N largest (or smallest) blobs from a binary image quite a bit because there's nothing built in to the Image Processing Toolbox to do that conveniently.
I also maintain an m-file that's nothing but random, assorted, commonly used snippets, called common_code.m. I often pull snippets from there when I build the demos I upload here.
Sean de Wolski
el 15 de Dic. de 2014
Editada: Sean de Wolski
el 15 de Dic. de 2014
The one I've been using a ton recently:
function mkcd(dirname)
% Make directory and navigate to it
% See Also: mkdir, cd
% One input expected, must be row string
narginchk(1,1)
validateattributes(dirname,{'char'},{'row'})
% Engine
mkdir(dirname)
cd(dirname)
end
2 comentarios
Sean de Wolski
el 15 de Dic. de 2014
Editada: Sean de Wolski
el 15 de Dic. de 2014
I've actually upped the quality of cll. It's now this:
evalin('base','clear')
close all force
clc
try
delete(findall(allchild(0)));
end
try
dbquit('all');
end
% Sean de Wolski
% Copyright 2014 The MathWorks, Inc.
% Kill the try/catch warning
%#ok<*TRYNC>
DGM
el 3 de Ag. de 2022
Editada: DGM
el 3 de Ag. de 2022
I know nobody needs a thread revival, but it's something that I'm constantly reminded of because I have to avoid it in posting things on the forum. I use MIMT imrange() all the time for fetching the global extrema of arrays. It's such a ridiculously simple and obvious convenience that losing it drives me bananas.
A = imread('cameraman.tif');
rg = imrange(A)
rg =
7 253
[mn mx] = imrange(A)
mn =
7
mx =
253
There are tons of things in MIMT that I think would qualify, but imrange() is the most simple, general, and frequent.
On the other hand, the most common non-TMW tool I use when on the forum is when(). Not that I use it super frequently, but I suppose If one needs to know the results of when(), one might need something like Rik's ifversion().
2 comentarios
Walter Roberson
el 3 de Ag. de 2022
DGM
el 3 de Ag. de 2022
The difference is that imrange() predates bounds(), and until you mentioned it, I had no idea that it existed (learn something new every day). I often prefer to have the output as a 2-element vector, so doing the same with bounds() isn't really much more convenient than using max() and min().
That was a bad example on my part. The result isn't like getrangefromclass(). It's the actual array extrema independent of the class. Maybe I should pick a different image for clarity.
Ver también
Categorías
Más información sobre Spreadsheets en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!