Effacer les filtres
Effacer les filtres

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

1 vue (au cours des 30 derniers jours)
Richard Hindmarsh
Richard Hindmarsh le 29 Juin 2012
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

Réponses (1)

Jan
Jan le 29 Juin 2012
Modifié(e) : Jan le 30 Juin 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;

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by