isblank.m
Determines if the argument string consists only of blanks.
Author: janez
thanks for your comments oleg. they were very useful and also my timings indicate all(isspace(x)) solution is most of the time 1.5-2 times faster than isblank and the x = all(x==blanks(length(x))) solution is about 20% faster.
i also noticed my complicated code is sometimes faster - how is that possible indeed? but good point there too: speedwise my code is the worst most of the time.
i'm sure it's clear from this which solution to use ;) but i'll keep my file posted anyway for pedagogical purposes - i don't want to extinguish your comment.
i'm running Matlab R2008a and cannot get ncx to work. when i try to load the file, i get the following error:
??? Error using ==> feval
Invalid MEX-file 'C:\Program Files\MATLAB\R2008a\work\ecomviz\ncx\netcdf\mexcdf\pcwin\mexcdf53.dll': C:\Program
Files\MATLAB\R2008a\work\ecomviz\ncx\netcdf\mexcdf\pcwin\mexcdf53.dll is not a valid Win32 program.
i tried to do what Mark Brandon suggested above but i cannot find mexcdf53.dll file in the latest sourcefourge directory and the error keeps repeating and the ncx doesn't work.
it's such a tease!
any thoughts anyone?
You can omit the call of BLANKS:
x = all(x==blanks(length(x)));
Faster (does not overwrite x, considers matrices):
y = all(x(:)==' ');
But ISSPACE catchs other invisible characters also:
y = all(x(:) <= ' '); % or <= 32
Because all characters with ASCII < 33 are invisible.
09 Sep 2010
isblank.m
Determines if the argument string consists only of blanks.
Author: janez
thanks for your comments oleg. they were very useful and also my timings indicate all(isspace(x)) solution is most of the time 1.5-2 times faster than isblank and the x = all(x==blanks(length(x))) solution is about 20% faster.
i also noticed my complicated code is sometimes faster - how is that possible indeed? but good point there too: speedwise my code is the worst most of the time.
i'm sure it's clear from this which solution to use ;) but i'll keep my file posted anyway for pedagogical purposes - i don't want to extinguish your comment.
08 Sep 2010
isblank.m
Determines if the argument string consists only of blanks.
Author: janez