Effacer les filtres
Effacer les filtres

How to remove 'e' from a matrix?

3 vues (au cours des 30 derniers jours)
Vishvachi Sinha
Vishvachi Sinha le 22 Avr 2020
Commenté : Stephen23 le 22 Avr 2020
I have an output matrix N = [12, 0.24e-16, 9]
want to remove e from the output matrix. I can do it from the command window by executing format short. But I want to do it in the code so that the output matrix is
N = [12, 0, 9]
How can I do this?
  2 commentaires
KSSV
KSSV le 22 Avr 2020
Read about fprintf
Stephen23
Stephen23 le 22 Avr 2020
"How to remove 'e' from a matrix?"
Numeric matrices do not store the character 'e', so it cannot be "removed" if it isn't there.
All you are seeing is the displayed representaton of a rather small value. If you think that such small values do not belong in your data, then you could replace them with some other, e.g. using indexing (as Stephan's answer shows) or round.

Connectez-vous pour commenter.

Réponses (1)

Stephan
Stephan le 22 Avr 2020
Modifié(e) : Stephan le 22 Avr 2020
N(N<1e-8)=0;
this will hard set all values smaller than 1e-8 to zero.
>> format shorte
>> N = [12, 0.24e-16, 9]
N =
1.2000e+01 2.4000e-17 9.0000e+00
>> N(N<1e-8)=0
N =
12 0 9

Catégories

En savoir plus sur Matrix Indexing dans Help Center et File Exchange

Tags

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by