Weird result using `==` operator in MATLAB -


im getting weird result using == in matlab_r2009b on os x. example prompt:

s =      2 >> class(s) ans = double >> class(s) == 'double' ans =      1     1     1     1     1     1 

six times yes? can explain || offer solution?

in matlab, strings arrays of characters. you're doing comparing 2 arrays. element-wise compare, i.e. character-by-character. could do:

all(class(s) == 'double') 

but give run-time error if string length of class(s) not 6. safer do:

strcmp(class(s), 'double') 

but should doing is:

isa(s, 'double') 

Comments

Popular posts from this blog

Add email recipient to all new Trac tickets -

400 Bad Request on Apache/PHP AddHandler wrapper -

php - Change action and image src url's with jQuery -