Hi guys; Please I need urgent help
I have matrix of experiment data in excel file, this excel matrix has some blank cells The problem is that the blank element shows as NaN when import the matrix to matlab for processing. Is there any function or .. to convert the Nan to zero
I appreciate your help.

 採用された回答

Laurent
Laurent 2013 年 8 月 25 日

45 投票

To set all NaN in Q to zero:
Q(isnan(Q))=0;
Is that what you need?

5 件のコメント

Abdulaziz
Abdulaziz 2013 年 8 月 25 日
easy,fast and smart I really appreciate your urgent respond . Thans
Walter Roberson
Walter Roberson 2017 年 6 月 11 日
Carlos Gamarra comments to Laurent:
Fast and simple
raf gm
raf gm 2017 年 9 月 3 日
thk
MAHMOUD ALZIOUD
MAHMOUD ALZIOUD 2017 年 12 月 15 日
Thank you
Ambati Sathvik
Ambati Sathvik 2020 年 5 月 22 日
Thank you so much!!

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

その他の回答 (2 件)

Santosh Shakya
Santosh Shakya 2021 年 12 月 24 日

2 投票

i want to replace nan with 0 in an array
can you help me?

1 件のコメント

Walter Roberson
Walter Roberson 2021 年 12 月 24 日
a = rand(5,5)
a = 5×5
0.9293 0.2265 0.4353 0.6769 0.2335 0.7836 0.5917 0.3524 0.9278 0.9782 0.3526 0.6221 0.5509 0.6242 0.4922 0.8690 0.6174 0.6444 0.7184 0.1279 0.6544 0.5207 0.1999 0.3623 0.0036
a([2, 7, 23]) = nan
a = 5×5
0.9293 0.2265 0.4353 0.6769 0.2335 NaN NaN 0.3524 0.9278 0.9782 0.3526 0.6221 0.5509 0.6242 NaN 0.8690 0.6174 0.6444 0.7184 0.1279 0.6544 0.5207 0.1999 0.3623 0.0036
b = fillmissing(a, 'constant', 0)
b = 5×5
0.9293 0.2265 0.4353 0.6769 0.2335 0 0 0.3524 0.9278 0.9782 0.3526 0.6221 0.5509 0.6242 0 0.8690 0.6174 0.6444 0.7184 0.1279 0.6544 0.5207 0.1999 0.3623 0.0036
%OR
c = a; c(isnan(c)) = 0
c = 5×5
0.9293 0.2265 0.4353 0.6769 0.2335 0 0 0.3524 0.9278 0.9782 0.3526 0.6221 0.5509 0.6242 0 0.8690 0.6174 0.6444 0.7184 0.1279 0.6544 0.5207 0.1999 0.3623 0.0036

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

Hernan Larriva
Hernan Larriva 2019 年 7 月 30 日

1 投票

Great, Thank you from Barcelona

カテゴリ

ヘルプ センター および File ExchangeDates and Time についてさらに検索

タグ

質問済み:

2013 年 8 月 25 日

コメント済み:

2021 年 12 月 24 日

Community Treasure Hunt

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

Start Hunting!

Translated by