Change value to NaN element

4 ビュー (過去 30 日間)
Giacomo Abrardo
Giacomo Abrardo 2021 年 4 月 27 日
コメント済み: Giacomo Abrardo 2021 年 4 月 27 日
Hi, i have a matrix 7938x498 with numerical and NaN values. I want to change value to some NaN elements but i don't know exactly their index in the matrix. I make an example to explain it better.
if i have a vector like this A=(NaN,NaN,NaN,NaN,NaN,1,5,7,9,NaN,NaN,NaN,NaN,5,5,53,3,NaN,NaN). How can i change the NaN values beetween 9 and 5 without change the others? Thanks
  5 件のコメント
Giacomo Abrardo
Giacomo Abrardo 2021 年 4 月 27 日
dqb i only need that they are finite. Doesn't matter the exact value
Giacomo Abrardo
Giacomo Abrardo 2021 年 4 月 27 日
that's part of the matrix. I need to change the value 3985 and 3989 from second column

サインインしてコメントする。

採用された回答

the cyclist
the cyclist 2021 年 4 月 27 日
Here is one way:
% The original data
A = [NaN,NaN,NaN,NaN,NaN,1,5,7,9,NaN,NaN,NaN,NaN,5,5,53,3,NaN,NaN];
% The indices of the numeric values
numericIndices = find(~isnan(A));
% The indices of the NaNs in the gap between the numeric values
gapIndices = setxor(min(numericIndices):max(numericIndices),numericIndices);
% Fill in the values you want to assign
A(gapIndices) = ...
  1 件のコメント
Giacomo Abrardo
Giacomo Abrardo 2021 年 4 月 27 日
that's work. Thank you very much

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by