Deleting NaN`s from a set of values using if loop

10 ビュー (過去 30 日間)
WILLBES BANDA
WILLBES BANDA 2020 年 3 月 28 日
コメント済み: Ameer Hamza 2020 年 3 月 28 日
I want to delete the NaN`s from A so that am left with numbers only and store them in the Absorption vector . When i execute/run my code it gives me the first value only(18.3402) and does not return the other values and sometimes it returns A as it is without removing NaN`s. please help
A=18.3402
18.3310
17.9390
16.1418
18.1064
22.6005
16.9847
22.5273
22.1760
16.8471
NaN
NaN
NaN
NaN
NaN
NaN
NaN
NaN
NaN
NaN
z = "NaN";
DeleteValues = strcmp(A,z );
Absorption = A(~DeleteValues)

採用された回答

Ameer Hamza
Ameer Hamza 2020 年 3 月 28 日
編集済み: Ameer Hamza 2020 年 3 月 28 日
A = [18.3402
18.3310
17.9390
16.1418
18.1064
22.6005
16.9847
22.5273
22.1760
16.8471
NaN
NaN
NaN
NaN
NaN
NaN
NaN
NaN
NaN
NaN];
A(isnan(A)) = [];
Result:
A =
18.3402
18.3310
17.9390
16.1418
18.1064
22.6005
16.9847
22.5273
22.1760
16.8471
  2 件のコメント
WILLBES BANDA
WILLBES BANDA 2020 年 3 月 28 日
It works perfectly fine, thank you so so much honourable
Ameer Hamza
Ameer Hamza 2020 年 3 月 28 日
Glad to be of help.

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

その他の回答 (0 件)

カテゴリ

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

製品

Community Treasure Hunt

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

Start Hunting!

Translated by