RESETREPLICATES

change the value of replicated elements in a matrix

現在この提出コンテンツをフォロー中です。

RESETREPLICATES - change the value of replicated elements in a matrix

For vectors, R = RESETREPLICATES(X) returns a vector R in which the re-ocurrences (replicates) of the values in X are set to NaN, except for their first occurrence. For 2-D matrices, RESETREPLICATES(X) looks for replicates in each column of X separately. For N-D arrays the function operates along the first non-singleton dimension of X.

RESETREPLICATES(X,DIM) operates along the dimension DIM. When DIM is empty, the function operates along the first non-singleton dimension.

RESETREPLICATES(X,[],V) sets all replicates to the value V instead of NaN. V must be a scalar. NaNs in X are ignored.

Examples:
resetreplicates([1 2 2 1 0 3 4 5 3 2])
% -> [1 2 NaN NaN 0 3 4 5 NaN NaN]

A = [1 0 0 1 ; 1 2 3 4 ; 2 2 5 1 ; 3 0 0 3]
resetreplicates(A) % = resetreplicates(A,1)
% 1 0 0 1
% NaN 2 3 4
% 2 NaN 5 NaN
% 3 NaN NaN 3

resetreplicates(A,2)
% 1 0 NaN NaN
% 1 2 3 4
% 2 NaN 5 1
% 3 0 NaN NaN

resetreplicates(A,1,0) % = resetreplicates(A,[],0)
% 1 0 0 1
% 0 2 3 4
% 2 0 5 0
% 3 0 0 3

See also unique, ismember
fillzero, replace (on the File Exchange)

Version 1.1 (oct 2008)

引用

Jos (10584) (2026). RESETREPLICATES (https://jp.mathworks.com/matlabcentral/fileexchange/21691-resetreplicates), MATLAB Central File Exchange. に取得済み.

カテゴリ

Help Center および MATLAB AnswersMatrices and Arrays についてさらに検索

一般的な情報

MATLAB リリースの互換性

  • すべてのリリースと互換性あり

プラットフォームの互換性

  • Windows
  • macOS
  • Linux
バージョン 公開済み リリース ノート Action
1.0.0.0

consistent naming into RESETREPLICATES