I have a matrix which looks like A = [1 NaN 1 ; NaN 1 2; NaN 1 2]; How can I remove all NaN's from the A matrix?

1 回表示 (過去 30 日間)
A = [1 NaN 1 ; NaN 1 2; NaN 1 2];

採用された回答

madhan ravi
madhan ravi 2018 年 11 月 7 日
編集済み: madhan ravi 2018 年 11 月 7 日
A = [1 NaN 1 ; NaN 1 2; NaN 1 2];
A(isnan(A))=[] ;
A = reshape(A,3,2)
command window:
>> COMMUNITY
A =
1 1
1 2
1 2
>>
  4 件のコメント
madhan ravi
madhan ravi 2018 年 11 月 7 日
B = [1 NaN, NaN,3,1;1 NaN, 1,NaN,1;1 NaN, 1,NaN,1;1 NaN, NaN,NaN,1;1 NaN, 2,NaN,1]
B(isnan(B))=[]
a=factor(numel(B));
m = max(a);
n=min(a);
reshape(B,m,n)

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

その他の回答 (2 件)

Rubel Ahmed
Rubel Ahmed 2018 年 11 月 7 日
Thanks mate , but If I have a matrix like B = [1 NaN, NaN,3,1;1 NaN, 1,NaN,1;1 NaN, 1,NaN,1;1 NaN, NaN,NaN,1;1 NaN, 2,NaN,1]; removing all NaN's from B,how can I reshape this matrix?

Rubel Ahmed
Rubel Ahmed 2018 年 11 月 7 日
Hi ravi,
please see the image. From the figure, the non-NaN elements of first row, are the neighbour particles of the first particle(1). then the non-NaN elements of second row, are the neighbour particles of the second particle. and so on. So I want to see the list of neighbour particles for particle 1 from first row which are 1 2 3 5 6 9. for the second row, I am happy to see like 1 2 3 4 5 6 7 , 3rd row will be like 1 2 3 4 6 7 8 12.

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by