Help with Matrices and Index Position

1 回表示 (過去 30 日間)
Michelle De Luna
Michelle De Luna 2021 年 2 月 3 日
回答済み: Michelle De Luna 2021 年 2 月 3 日
Hi all,
I have multiple matrices of the same size (500 x 5,000). I am focusing on the first of the matrices, which has some numerical values as well as some NaN's in each column. What I am trying to do is identify only the indices of the numerical values (not the NaN's) in the first matrix so that I can then look at the other matrices and find the value recorded at the same index position. (For example, if the first matrix has a number in the fifth row of the first column, I would like to find the value at the fifth row of the first column for ALL matrices.) Any suggestions? I think it may have to do with sub2ind, but I'm unsure how to apply that function.
Thanks in advance.
x = 500 x 5000 (This variable, "x", represents the matrix I am focusing on, i.e. the one within which I am looking for numerical values.)
day = 500 x 5000
month = 500 x 5000
year = 500 x 5000

採用された回答

Michelle De Luna
Michelle De Luna 2021 年 2 月 3 日
Thanks to all! I just used the "find" function to find all non-NaN values and used the indices related to these values to solve my question. Again, thanks!
ind = find(~isnan(x))
q = x(ind)
d = day(ind)
m = month(ind)
y = year(ind)
[q d m y]

その他の回答 (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