Info

この質問は閉じられています。 編集または回答するには再度開いてください。

How can I convert a matrix to all numeric values which contains numeric and characters both?

1 回表示 (過去 30 日間)
Zara Khan
Zara Khan 2018 年 8 月 9 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
I have matrix containing both numerics and characters(actually NaNs) values both. How to convert this matrix so that it contains all the numeric values?Because I want to write this matrix to an excel sheet.
  2 件のコメント
Stephen23
Stephen23 2018 年 8 月 10 日
"I have matrix containing both numerics and characters(actually NaNs) values both"
What does this mean exactly: do you have a numeric matrix? NaN's in a numeric matrix are numeric, so your description is not clear.
Zara Khan
Zara Khan 2018 年 8 月 12 日
I only want replace NaNs by zero thats it.

回答 (1 件)

Rik
Rik 2018 年 8 月 9 日
If you want to replace the NaNs by 0, you can simply use this:
data(isnan(data))=0;
  4 件のコメント
Zara Khan
Zara Khan 2018 年 8 月 12 日
編集済み: Zara Khan 2018 年 8 月 12 日
I am passing the entire matrix and getting a logical matrix always. That I dont want.
Rik
Rik 2018 年 8 月 12 日
If your variable data is a matrix that is not a logical, this code will not return a logical. What exact code are you using? Try to reduce it to a small piece of code I can run to replicate your issue.

この質問は閉じられています。

Community Treasure Hunt

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

Start Hunting!

Translated by