Rank: 3617 based on 27 downloads (last 30 days) and 2 files submitted
photo

Manel Soria

E-mail

Personal Profile:

 

Watch this Author's files

 

Files Posted by Manel Soria View all
Updated   File Tags Downloads
(last 30 days)
Comments Rating
03 Oct 2013 Screenshot AGA 1.0 Genetic Algorithm code with/without islands and Simulated Annealing Author: Manel Soria optimization, mathematics 20 1
  • 4.0
4.0 | 1 rating
05 Mar 2013 quickfindstr Finds the index of an element in a SORTED list of strings in O(log(N)) time Author: Manel Soria demo, data import, statistics 7 5
Comments and Ratings by Manel Soria View all
Updated File Comments Rating
12 Jun 2014 julian2greg This function converts the Julian dates to Gregorian dates. Author: Gabriel Ruiz

Thanks !

08 Mar 2013 quickfindstr Finds the index of an element in a SORTED list of strings in O(log(N)) time Author: Manel Soria

First, thanks for your comment, I see that strmatch isn't a good choice at all.
It seems there is a small mistake in your code, should it be c{k} = sprintf('%d', k); in the second line ?
My timings are different:
tic; for i=1:100:n; f= quickfindstr(c{i}, c); end; toc
% 4.697042
tic; for i=1:100:n; f= find(strcmp(c{i}, c)); end; toc
% 6.770262
tic; for i=1:100:n; f= strmatch(c{i}, c, 'exact'); end; toc
% 48.737699
What Matlab version are you using ? On what machine ? I'm running 2011b on a late 2009 Imac
To conclude, I tested the following
>> tic; for i=1:100; f= find(strcmp(c{1}, c)); end; toc
Elapsed time is 0.385195 seconds.
>> tic; for i=1:100; f= find(strcmp(c{150000}, c)); end; toc
Elapsed time is 0.469383 seconds.
Thus, strcmp isn't just a linear search algorithm as I expected. I wonder how is it working

06 Mar 2013 quickfindstr Finds the index of an element in a SORTED list of strings in O(log(N)) time Author: Manel Soria

Thanks for the comment !
Can you please post how you do it and the time it takes ?
In any case, a sequential strcmp will be a O(N) operation and for large sets this method, O(logN) should be faster

28 Feb 2013 X Steam, Thermodynamic properties of water and steam. Water properties A complete IAPWS IF-97 standard. Author: Magnus Holmgren

Excellent !!

23 Jan 2013 Making Surface Plots From Scatter Data How to turn a collection of XYZ triplets into a surface plot. Author: Zain Mecklai

Thanks !

Comments and Ratings on Manel Soria's Files View all
Updated File Comment by Comments Rating
29 Oct 2013 AGA 1.0 Genetic Algorithm code with/without islands and Simulated Annealing Author: Manel Soria Fabien

really nice (i've tested only AGA)

15 Apr 2013 quickfindstr Finds the index of an element in a SORTED list of strings in O(log(N)) time Author: Manel Soria Jan Simon

@Manel: Thanks for fixing the typo. I've meaured the timings on a Core2Duo/2009a/64/Win7 system.

strcmp(c{150000}, c) needs longer than for c{1}, because the contents of c{1} is shorter. There are only 9 strings in c, which have one character only, while for C{150000}='150000' there are a lot of strings with size 6, such that an explicit comparison is started. In addition, a comparison of a shorter string is faster than of a longer string, because less bytes have to be processed.

08 Mar 2013 quickfindstr Finds the index of an element in a SORTED list of strings in O(log(N)) time Author: Manel Soria Manel Soria

First, thanks for your comment, I see that strmatch isn't a good choice at all.
It seems there is a small mistake in your code, should it be c{k} = sprintf('%d', k); in the second line ?
My timings are different:
tic; for i=1:100:n; f= quickfindstr(c{i}, c); end; toc
% 4.697042
tic; for i=1:100:n; f= find(strcmp(c{i}, c)); end; toc
% 6.770262
tic; for i=1:100:n; f= strmatch(c{i}, c, 'exact'); end; toc
% 48.737699
What Matlab version are you using ? On what machine ? I'm running 2011b on a late 2009 Imac
To conclude, I tested the following
>> tic; for i=1:100; f= find(strcmp(c{1}, c)); end; toc
Elapsed time is 0.385195 seconds.
>> tic; for i=1:100; f= find(strcmp(c{150000}, c)); end; toc
Elapsed time is 0.469383 seconds.
Thus, strcmp isn't just a linear search algorithm as I expected. I wonder how is it working

07 Mar 2013 quickfindstr Finds the index of an element in a SORTED list of strings in O(log(N)) time Author: Manel Soria Jan Simon

Some tests under Matlab 2009a/64/Win7:

n = 150000; c = cell(1, n);
for k = 1:n; c = sprintf('%d', k); end;
c = sort(c);
tic; for i=1:100:n; f= quickfindstr(c{i}, c); end; toc
% 6.043004 seconds
tic; for i=1:100:length(c); f= find(strcmp(c{i}, c)); end; toc
% 7.903860 seconds
tic; for i=1:100:length(c); f= strmatch(c{i}, c, 'exact'); end; toc
% 56.037904 seconds

For n=15'000 the timings are:
quickfindstr: 0.437317 seconds
find(strcmp): 0.054181 seconds
strmatch: 0.417264 seconds

This shows, that for 150'000 strings you methods beats find(strcmp).

06 Mar 2013 quickfindstr Finds the index of an element in a SORTED list of strings in O(log(N)) time Author: Manel Soria Manel Soria

Thanks for the comment !
Can you please post how you do it and the time it takes ?
In any case, a sequential strcmp will be a O(N) operation and for large sets this method, O(logN) should be faster

Contact us