How to fix a number equal to null in MATLAB

3 visualizaciones (últimos 30 días)
Nisar Ahmed
Nisar Ahmed el 13 de Ag. de 2020
Comentada: Nisar Ahmed el 13 de Ag. de 2020
Hello
I have a lot values (equal to -999.25) in my data columns. I want that matlab read these values (-999.25) as zero when ever I load or run my data on MATLAB. How can I fix this problem? Please help

Respuesta aceptada

源樹 上林
源樹 上林 el 13 de Ag. de 2020
a = [ 1 2 3 -999.25 -999.25 4 5]
a(a == -999.25) = 0
  7 comentarios
Walter Roberson
Walter Roberson el 13 de Ag. de 2020
DTP = clew(DTP);
DRZ = clew(DRZ) ;
function A = clew(A)
A(A==-999.25) = nan;
So you would have 10 lines of assignment, one for each variable.
Yes it is possible to do it in fewer lines with more confusing code.
But better would have been to store all of the arrays in the same variable, such as a multidimensional array or cell array or struct. Any of those could have all fields processed easily, like
Dats = structfun(@clew, Dats, 'uniform', 0)
Nisar Ahmed
Nisar Ahmed el 13 de Ag. de 2020
Roberson,
Thanks

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Characters and Strings en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by