フィルターのクリア

Info

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

Can we do matrix operations on a matrix that might contain NaNs in it?

1 回表示 (過去 30 日間)
SSG_newbiecoder
SSG_newbiecoder 2018 年 3 月 17 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
Hello, This is not any doubt in matlab but about matrices. I have a feature matrix of an ECG signal. It can have NaN elements. For example, I find P duration. So if either P_onset or P_offset is not there, P duration is a NaN. So, on such a matrix, can I perform any matrix operations such as sum of diagonal elements etc?

回答 (1 件)

James Tursa
James Tursa 2018 年 3 月 17 日
編集済み: James Tursa 2018 年 3 月 17 日
You can do any operation you want with the matrix, but the NaN's will propagate through all of the calculations. That is, in general once you involve a NaN in a numeric calculation the result will be a NaN. There will be no warning or message telling you that this has happened ... you will need to check your results to see if there are any NaN's in the result. See the isnan( ) function for this.
  2 件のコメント
SSG_newbiecoder
SSG_newbiecoder 2018 年 3 月 17 日
So, should I replace the NaNs somehow with something else?
James Tursa
James Tursa 2018 年 3 月 17 日
That depends entirely on how you will be using the results downstream in your code. Sometimes NaN's are useful ... e.g. for plotting. But other times they simply screw up the downstream calculations and you need to either replace them with something else (e.g. 0 or very small number) or delete them from the variable entirely. What is the best for your situation? We can't advise you on that since we don't know all of the details for how it will be used.

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

Community Treasure Hunt

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

Start Hunting!

Translated by