필터 지우기
필터 지우기

For consistency with "nan", wouldn't it be nice to be able to issue "missing(3)"?

조회 수: 3 (최근 30일)
FM
FM 2022년 4월 26일
댓글: Bruno Luong 2022년 4월 27일
<Missing> is the string counterpart to NaN. One can define a (say) 3x3 array of NaN's. Each NaN can be replaced as the data is generated in the analysis process, which is handy if the data isn't generated simultaneously. At no point is there any confusion between NaN versus a valid zero datum.
It would be nice to be able to do this for strings. Of course, one can issue "string(nan(3))" or "repmat(missing,3,3)". But as code gets more intricate, simplicity becomes more valuable.
  댓글 수: 11
FM
FM 2022년 4월 27일
@Jan: In 2019a, missing(2,3) and missing(2,3,'string') are not recognized. I'm still waiting to upgrade. The command "doc missing" yields a very sparse documentation page....
Jan
Jan 2022년 4월 27일
@FM: In R2022a this syntax is not working also - you can try this here in the forum's interpreter:
missing(2,3,'string')
Error using missing
Too many input arguments.
So this is a useful enhancement request. Please use the link on the bottom of this page to contact the MathWorks team and suggest this improvement.

댓글을 달려면 로그인하십시오.

답변 (1개)

Bruno Luong
Bruno Luong 2022년 4월 27일
Why not define your own function
mymissing
ans = missing
<missing>
mymissing(3)
ans = 3×3 missing array
<missing> <missing> <missing> <missing> <missing> <missing> <missing> <missing> <missing>
mymissing(2,3)
ans = 2×3 missing array
<missing> <missing> <missing> <missing> <missing> <missing>
mymissing(2,'string')
ans = 2×2 string array
<missing> <missing> <missing> <missing>
mymissing(2,3,'double')
ans = 2×3
NaN NaN NaN NaN NaN NaN
function x = mymissing(varargin)
% x = mymissing(size)
% x = mymissing(n1, n2, ...)
% x = mymissing(..., class)
x = missing;
if ~isempty(varargin)
if ischar(varargin{end}) || isstring(varargin{end})
sz = [varargin{1:end-1}];
if isempty(sz)
sz = 1;
end
cls = varargin{end};
x = repmat(feval(cls,x), sz);
else
sz = [varargin{1:end}];
x = repmat(x, sz);
end
end
end
  댓글 수: 12
FM
FM 2022년 4월 27일
@Bruno Luong: No, I should have been clearer. the 2019a documentation for "missing" does not describe it a specific to "string". I got that from the page cited in my last reply. Which is a very specific page for strings and missing values.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by