Search Comments and Ratings

go

Comments and Ratings

   
Date File Comment by Comment Rating
04 Nov 2009 Recursive addpath Recursively adds directories to MATLAB path, optionally ignores some Author: Anthony Kendall Kendall, Anthony

Thanks Jim!

I made that change for compatibility with Macs. Also, based on your first comment back in October I increased the speed of the code by a factor of 3 in a moderate-sized directory tree.

02 Nov 2009 Recursive addpath Recursively adds directories to MATLAB path, optionally ignores some Author: Anthony Kendall Jim

It seems I can't figure out how to work this comment system. The main point of the last post was that the code doesn't work on a MAC as strStarDir\*. doesn't work, it only returns . and ..

02 Nov 2009 Recursive addpath Recursively adds directories to MATLAB path, optionally ignores some Author: Anthony Kendall Jim

OOPS, that second part should read:
saSubDirs = dir(strStartDir);
saSubDirs = saSubDirs([saSubDirs.isdir]);

12 Oct 2009 Recursive addpath Recursively adds directories to MATLAB path, optionally ignores some Author: Anthony Kendall Jim

12 Oct 2009 Recursive addpath Recursively adds directories to MATLAB path, optionally ignores some Author: Anthony Kendall Jim

Just to clarify on that last point, keeping a cell array of all directories to process, then using addpath(pathsOut{:},strXorIntAddpathMode) (where pathsOut is a cell array of all paths to add) works well

22 May 2009 Date to Decimal Day of Year Convert a vector of MATLAB serial dates to decimal days since the start of the year. Author: Anthony Kendall Ashley

I just submitted a doy2date.m. Thanks to both Anthony and James for the inspiration.

22 May 2009 Date to Decimal Day of Year Convert a vector of MATLAB serial dates to decimal days since the start of the year. Author: Anthony Kendall Ashley

I am giving this a higher rating now because it is named properly and the new code can handle vectors. Thanks!

28 Apr 2009 Date to Decimal Day of Year Convert a vector of MATLAB serial dates to decimal days since the start of the year. Author: Anthony Kendall Kendall, Anthony

Ashley,
Not sure why FEX didn't have the date2doy. Should have been updated last January 18th, but something must have gone wrong there. I resubmitted the function.

27 Apr 2009 Date to Decimal Day of Year Convert a vector of MATLAB serial dates to decimal days since the start of the year. Author: Anthony Kendall Ashley

The file that I downloaded is called date2julian when it should be called date2doy according to the file information.

I was looking for a function to convert from MATLAB serial date format to a day of year (1-365) and this one does that. It is just that the file name and documentation is misleading witht he mention of Julian dates.

08 Apr 2009 Determine and count unique values of an array Very fast function to determine and count unique values of numeric, logical, char, cell arrays. Author: Anthony Kendall matthews, dave

it would be nice to extend this to the n-d case, or at least the 2-d case, i.e., find and list unique pairs?

x = [1 2; 1 3; 1 2];
then, uniques = [1 2], [1 3];
and, numuniques = [2 1];

thanks

08 Apr 2009 Determine and count unique values of an array Very fast function to determine and count unique values of numeric, logical, char, cell arrays. Author: Anthony Kendall Ilya

21 Mar 2009 Determine and count unique values of an array Very fast function to determine and count unique values of numeric, logical, char, cell arrays. Author: Anthony Kendall Kendall, Anthony

Bruno,
Thanks for making this point. This can be addressed by specifying the 'float' option in count_unique. However, I've added also added a check that when the maximum value of the input array is much greater than its number of elements, accumarray is not used.

I ran your example on the unmodified code, and got results similar to yours. Now, on the modified code (without specifying the 'float' option, which does not use accumarray), the run times are both trivial in your example. The change increased run times for large array integer values slightly, and the description above is modified to reflect that.

Thanks again.

21 Mar 2009 Determine and count unique values of an array Very fast function to determine and count unique values of numeric, logical, char, cell arrays. Author: Anthony Kendall Luong, Bruno

Inside the code, the author uses ACCUMARRAY on the values of the input array. This is a poor choice because it might create a large chunk of memory and slow down greatly.

Here is a code to check this effect. On my computer the worse time is 2.5 s, and unique can accomplish in less than 1 ms.

power=1:64;
time=zeros(length(power),2);

for k=1:length(power)
    
    twoelem=[0 2.^power(k)-1];
    disp(twoelem)
    
    tic
    count_unique(twoelem);
    time(k,1) = toc;
    
    tic
    unique(twoelem);
    time(k,2) = toc;
end
fprintf('worse time = %g s\n', max(time,[],1))
plot(power,time);
ylabel('second');
title('Time for array of two elements')
legend('count unique','unique')

18 Mar 2009 Determine and count unique values of an array Very fast function to determine and count unique values of numeric, logical, char, cell arrays. Author: Anthony Kendall D'Errico, John

Ok. That was quick. This is looking better now. As a potential downloader, the description gives me some reason to use it, especially if I'm looking to squeeze some speed out of a tight piece of code.

A look inside the code is always interesting. I like to see when the author has taken care in the code. Friendly code worries about things like the presence of nans, infs, different variable classes, etc. Also lots of comments. White space. Intelligently named, mnemonic variable names. These things make any piece of code an easy read, and easy to debug in the future.

Good help, examples. etc. All well done. Thanks for the changes.

18 Mar 2009 Determine and count unique values of an array Very fast function to determine and count unique values of numeric, logical, char, cell arrays. Author: Anthony Kendall Kendall, Anthony

John,
The code is primarily used to count the number of each unique instance within an array, but as a side benefit is slightly faster than the existing unique function (and quite a bit faster for integer-valued arrays). I'll modify the description to make this more obvious.

Thanks for your comments.

18 Mar 2009 Determine and count unique values of an array Very fast function to determine and count unique values of numeric, logical, char, cell arrays. Author: Anthony Kendall D'Errico, John

I'm confused. Even the author admits this is only slightly faster than the existing unique, and that the main reason is probably because it does not bother to check the arguments. He also admits that it has considerably less capability than the existing unique.

Anyone truly in need of the maximum speed is better off with a direct call to accumarray anyway, which will further reduce any overhead.

Why does this exist? Perhaps some time comparisons might be of value, and some examples that show why this is a better choice than the existing alternatives.

The code does look to be carefully written at a glance, and the help seems reasonable, were I to rate this.

25 Nov 2008 Recursive addpath Recursively adds directories to MATLAB path, optionally ignores some Author: Anthony Kendall Sven

You can avoid the first bug I mentioned above by adding the following at line 59:
currDir = currDir([currDir.isdir]);

Oh, and I just checked in genpath, and see that IT uses recursive calls to 'dir'. Therefore my second suggestion doesn't actually avoid these multiple calls!

25 Nov 2008 Recursive addpath Recursively adds directories to MATLAB path, optionally ignores some Author: Anthony Kendall Sven

Thank you for this very useful function. I have two main comments:
1. I think that there's a bug that causes the function to crash if a file without ANY extension is in a directory. For example, some people submit file exchange packages that include a file called "README". Your function fails on this case (at the moment).

2. I haven't checked yet, but perhaps this could be rewritten without using recursive functions. I think that if you simply use genpath to get a list of directories, you could then filter this list all in one go. This may be a little faster.

Nice function!

25 Nov 2008 Recursive addpath Recursively adds directories to MATLAB path, optionally ignores some Author: Anthony Kendall Dalon, Thierry

Be aware: you are using assert function. This is not available in R14 or previous!
Moreover I am not sure if assert exit the function...

25 Nov 2008 Recursive addpath Recursively adds directories to MATLAB path, optionally ignores some Author: Anthony Kendall Dalon, Thierry

it is not possible to change a rating in this new FX...sorry for the previous rating.
I think now it is a very useful file. Thanks for updating!
One last suggestion: I would consider a default ignore value possible in the script. For example, if no ignore input argument use ignore = {'.svn'}, editable by the user so that users can simply call your file without passing always an ignore option if they have a predilected default value.

25 Nov 2008 Recursive addpath Recursively adds directories to MATLAB path, optionally ignores some Author: Anthony Kendall Dalon, Thierry

24 Nov 2008 Generalized Objective Function Allows any MATLAB function to easily be optimized Author: Anthony Kendall mittal, bipin

21 Nov 2008 Recursive addpath Recursively adds directories to MATLAB path, optionally ignores some Author: Anthony Kendall Dalon, Thierry

@Author: the idea of an ignore option is good.
Good would be if you could also directly pass through ignore filter like "all directories starting wih "@" or "#"". At the best would be generic wildcard expressions.
Small missing point:Your implementation does not allow to use addpath intrinsec option like -BEGIN and -END.
You removed some features from original Matlab GENPATH which make your version not optimized. (private and @ not ignored by default; your loop run also over all files!)
------
@Jesse: this can be done with a small correction in the code:
if ~any(strcmp(currDir(m).name,{'.','..',ignore{:}})) && currDir(m).isdir && ~strncmp(currDir(m).name,'@',1) && ~any(strcmp(currDir(m).name,{'private','.',,'..')) ...
(see also original GENPATH)

20 Nov 2008 Recursive addpath Recursively adds directories to MATLAB path, optionally ignores some Author: Anthony Kendall Hopkins, Jesse

Works pretty good, but it doesn't automatically ignore "private" directories and "@" directories like genpath does. You can easily add "private" to the list of ignored directories, however being able to skip over all "@" directories requires some code change.

28 Sep 2008 Generalized Objective Function Allows any MATLAB function to easily be optimized Author: Anthony Kendall Kendall, Anthony

Thanks for the tip about anonymous functions, I do see how they work now.

However, you are wrong that this is EXACTLY what the anonymous functions do. To minimize and objective function in general like this, you will either need separate m-files for your various objective functions, or will have to re-create them as anonymous functions every time you use them. There are TWO function calls here: 1) to the actual MATLAB function which you are minimizing, and 2) to the objective function that will evaluate the target function's output and provide a single value for optimization.

I encourage anyone embedding optimization in larger programs, or working with optimization that involves multiple target functions and different objective functions to give this a try.

This function is simpler than anonymous functions, and though duplicate in some fashions, not necessarily useless.

As far as the "ugly" line, that is how function handles are defined using variable inputs. Sometimes eval is necessary, even though it is not the most optimizable MATLAB facility.

I corrected my mistake about the version numbering, thank you for that.

26 Sep 2008 Generalized Objective Function Allows any MATLAB function to easily be optimized Author: Anthony Kendall x@y.z, Jos

It DOES fail on <7 releases, e.g. due to ugly (sic!) lines like this "funcHandle = eval(['@',funcName]);"
So, stick to anonymous functions, or use inline functions in <7 releases.

Nonetheless, thumbs up for the help, H1 line, ample comments, and example. I decided to rate it with 1 star since it does not add anything of value to recent releases.

26 Sep 2008 Generalized Objective Function Allows any MATLAB function to easily be optimized Author: Anthony Kendall D'Errico, John

It IS what anonymous functions do for us. And, they will do it far better and more easily than this submission. Plus, they will surely be more efficient.

The only reason I did not say anything immediately when this appeared is this submission is claimed to work on older releases of Matlab, and anonymous functions were introduced only in version 7. Since that ability is untested by the author and I am unable to test it, I won't say anything more, nor should I provide a rating.

26 Sep 2008 Generalized Objective Function Allows any MATLAB function to easily be optimized Author: Anthony Kendall Meldolesi, Riccardo

I thought that this was what anonymous functions were for. Am I missing something here?

15 Aug 2008 Recursive addpath Recursively adds directories to MATLAB path, optionally ignores some Author: Anthony Kendall Kendall, Anthony

Genpath is unable to ignore directories, which is a key feature for certain uses (like source code repositories). That's the real utility of this function.

15 Aug 2008 Recursive addpath Recursively adds directories to MATLAB path, optionally ignores some Author: Anthony Kendall Roossien, B.

What is wrong with addpath(genpath())?

18 May 2008 Unit Conversion A simple unit conversion function that is easily extended. Author: Anthony Kendall le, chen

18 Jan 2008 Date to Decimal Day of Year Convert a vector of MATLAB serial dates to decimal days since the start of the year. Author: Anthony Kendall Kendall, Anthony

Thanks, James, for your comments. You've helped me to make the code clearer and
faster.

I completely rewrote the function and resubmitted it.

I don't think it's as trivial as you suggest.

Also, Julian Day is very often in the Environmental Sciences used to refer to the day of the year. Terminology like that, essentially jargon, can have different definitions from field to field. But, to avoid confusion I've gone ahead and changed it to "doy" as you suggested.

14 Jan 2008 Date to Decimal Day of Year Convert a vector of MATLAB serial dates to decimal days since the start of the year. Author: Anthony Kendall Tursa, James

I did not give this submission a good rating for the following reasons:

1) This routine basically returns the day of the year, not a Julian day. The term Julian day should be reserved for the astronomical definition of days since noon Universal Time (UT) Monday, January 1, 4713 BC. So the name of the function and the description should be something like datenum2doy.m, or the like. Descriptions like "... Julian days since the start of the year ... " are ambiguous and should be removed.

2) This routine takes a datenum type of variable as an input, but the variable name used by the author is date, and date is an existing MATLAB function name. This may be confusing to users. The name of the input date variable should be changed.

3) The functionality provided by this routine is fairly simple. For example, the following few MATLAB lines essentially do the same thing for the day-of-year calculation and are just as fast:

function doy = datenum2doy(dn)
dv = datevec(dn);
dv(:,2:end) = 0;
doy = dn - datenum(dv);
end

In summary, I gave this submission a low score because of the simple functionality provided and the misuse of the Julian day terminology. The author did comment his code, which is why I gave it a 2 instead of a 1. (you should always give people who comment their code *some* reward).

James Tursa

06 Sep 2007 Unit Conversion A simple unit conversion function that is easily extended. Author: Anthony Kendall zq, l

 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com