Borrar filtros
Borrar filtros

Former behaviour of ~NaNs (of interest to Matlab users from mid-90s)

1 visualización (últimos 30 días)
Hallo
I am running (for the first time since I wrote it) a Matlab script from 1996. In it I have a line where
a = ~b;
where b contains some NaNs. This used to run, but now, with the advent of the logical type, it won't accept ~NaN;
>> ~NaN Error using ~ NaN's cannot be converted to logicals.
But what was the value of ~NaN in those days? was it 0 or 1?
Thanks

Respuestas (1)

Jan
Jan el 29 de Jun. de 2012
Editada: Jan el 30 de Jun. de 2012
1996 sounds like Matlab 4.2c or 5.0. In these times logical 's have been double 's with an extra flag. This has been change in 6.5.
I assume, that ~NaN has been NaN, even as logical type. But in the documentation I find "TRUE is everything but 0". I will try this in the evening with Matlab 5.3.
[EDITED: after running a test in Matlab 5.3]:
a = ~NaN;
disp(a)
% >> 0
class(a)
% >> double
islogical(a)
% >> 1
Therefore I assume this is required for your program:
b(isnan(b)) = 1; % Anything but 0
a = ~b;

Categorías

Más información sobre Logical en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by