Azzera filtri
Azzera filtri

RMS Function Returns NAN

30 visualizzazioni (ultimi 30 giorni)
Mark Lafrentz
Mark Lafrentz il 11 Giu 2019
Commentato: Mark Lafrentz il 12 Giu 2019
I am using the 'rms' function to calculate root mean squared values. For certain portions of data, the function returns NAN. There is good, non-zero data in the array i'm inputting (2000 data points all non-zero). I know how to calculate rms values myself, but for the sake of learning, i would like to know why this is happening.

Risposta accettata

Greg Dionne
Greg Dionne il 11 Giu 2019
It's likely you have NaN in your input, or your input is an empty vector.
If you wish to exclude NaN values from computation, then you can try:
sqrt(mean(x .* x, 'omitnan'))
Hope this helps,
-Greg
  1 Commento
Mark Lafrentz
Mark Lafrentz il 12 Giu 2019
You were right. I had one NAN in my data set. Thank you!

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Line Plots in Help Center e File Exchange

Tag

Prodotti


Release

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by