Added workaround for bug in some Matlab versions (wrong type).