Rank: 2726 based on 50 downloads (last 30 days) and 3 files submitted
photo

Paulo Buchsbaum

E-mail

Personal Profile:
Professional Interests:

 

Watch this Author's files

 

Files Posted by Paulo View all
Updated   File Tags Downloads
(last 30 days)
Comments Rating
07 Oct 2010 Class for character array Class for easier string manipulation, with many operators and functions overloads. Author: Paulo Buchsbaum character array, trimming, padding, trim, instr, left 16 2
  • 4.0
4.0 | 1 rating
30 Sep 2010 Matrix IIF Returns first or second expression depending of a condition result Author: Paulo Buchsbaum matrix, conditional, iif, mathematics, character array 20 0
23 Sep 2010 Matrix IIF Returns first or second expression depending of a condition result Author: Paulo Buchsbaum matrix, conditional, iif, mathematics 14 0
Comments and Ratings by Paulo View all
Updated File Comments Rating
02 Jan 2012 Harmony Search Algorithm Meta-heuristic Optimization Method Author: Mohammad Fesanghary

This code helps understand the power of harmony search.

02 Jan 2012 Harmony Search Algorithm Meta-heuristic Optimization Method Author: Mohammad Fesanghary

06 Oct 2010 Class for character array Class for easier string manipulation, with many operators and functions overloads. Author: Paulo Buchsbaum

Cris Luengo

Thanks for your comments.
It's was very useful for making a "best class" character array handling.

I've submitted a updated version.

Comments and Ratings on Paulo's Files View all
Updated File Comment by Comments Rating
06 Oct 2010 Class for character array Class for easier string manipulation, with many operators and functions overloads. Author: Paulo Buchsbaum Buchsbaum, Paulo

Cris Luengo

Thanks for your comments.
It's was very useful for making a "best class" character array handling.

I've submitted a updated version.

05 Oct 2010 Class for character array Class for easier string manipulation, with many operators and functions overloads. Author: Paulo Buchsbaum Luengo, Cris

I like being able to compare strings with the comparison operators! The code you wrote for comparisons is very much in the Basic style, not so much in the MATLAB style. You'll find that this function is faster:

function r = compare_strings(a,b)
% returns: 0 == equal
% 1 == a is larger
% -1 == b is larger
a = str(a); a = a.s;
b = str(b); b = b.s;
la = length(a);
lb = length(b);
l = min(la,lb);
r = a(1:l)-b(1:l);
[~,~,r] = find(r,1,'first');
if ~isempty(r)
r = sign(r);
else % they're equal, compare lengths
if la==lb
r = 0;
elseif la<lb
r = -1;
else
r = 1;
end
end
end

function r = lt(a,b)
r = compare_strings(a,b)<0;
end

(etc.)

Whenever you have two or more 'str' inputs, it is nice to convert those inputs to class 'str' explicitly. That way, it is possible to mix an object of class 'str' with a different class, for example:
a=str('hello')
a < 'goodbye'

If you do a similar conversion for the '[]' and '+' operation, you can do something like:
a=str('hello')
a = [' ',a,' ',5]

I would also overload the '*' as your 'repeat' function. Makes sense to me:
str('hello')*5

You also need to overload 'cat' and 'vertcat' methods. Rigth now, you get an error when you do [a;a]. It creates an object with 2 strings in it, which the 'disp' function cannot display.

Contact us