Effacer les filtres
Effacer les filtres

Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

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

1 vue (au cours des 30 derniers jours)
Zara Khan
Zara Khan le 9 Août 2018
Clôturé : MATLAB Answer Bot le 20 Août 2021
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 commentaires
Stephen23
Stephen23 le 10 Août 2018
"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 le 12 Août 2018
I only want replace NaNs by zero thats it.

Réponses (1)

Rik
Rik le 9 Août 2018
If you want to replace the NaNs by 0, you can simply use this:
data(isnan(data))=0;
  4 commentaires
Zara Khan
Zara Khan le 12 Août 2018
Modifié(e) : Zara Khan le 12 Août 2018
I am passing the entire matrix and getting a logical matrix always. That I dont want.
Rik
Rik le 12 Août 2018
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.

Cette question est clôturée.

Community Treasure Hunt

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

Start Hunting!

Translated by