フィルターのクリア

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

1 回表示 (過去 30 日間)
Richard Hindmarsh
Richard Hindmarsh 2012 年 6 月 29 日
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

回答 (1 件)

Jan
Jan 2012 年 6 月 29 日
編集済み: Jan 2012 年 6 月 30 日
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;

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by