Former behaviour of ~NaNs (of interest to Matlab users from mid-90s)
조회 수: 1 (최근 30일)
이전 댓글 표시
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
댓글 수: 0
답변 (1개)
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;
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!