How to plot taking into account the NaN positions?

2 ビュー (過去 30 日間)
Sara Antonio
Sara Antonio 2016 年 10 月 13 日
コメント済み: KSSV 2016 年 10 月 13 日
I'm comparing data with the same x length in several subplots. However, sometimes my data starts/end with NaN and when ploted the x changes dimensions ignoring the first/last NaN values. I don't want to substitute the NaN values because they are part of my data. I also tried to make it plot "all", but keeps ignoring the first/last NaN. How can I plot my data maintaining the complete length of x without ignoring the first/last NaN?

回答 (1 件)

KSSV
KSSV 2016 年 10 月 13 日
NaN cannot be plotted. If NaN appears in between, the data breaks there and then plots. If you want to keep the data same and want to plot the NaN places also, you have to fill these NaN values using some gap filling techniques Eg. interpolation would be easy and straight forward.
  2 件のコメント
Sara Antonio
Sara Antonio 2016 年 10 月 13 日
You mean the only way possible to maintain the length of x is indeed attribute some value to the first/last NaN of my data? There is no possible way to start/end my plot with empty space? My problem is that I cannot make up or interpolate data if in reality I don't have data for that x. I would be manipulating my analysis..
KSSV
KSSV 2016 年 10 月 13 日
Though NaN is there, The dimensions of (x,y) are maintained. Else it would have thrown error. For calculation parts, you can discard the respective NaN parts, whcih reduces the dimension. If you insist on having the dimensions same, do interpolation to fill the NaNs.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeCorrelation and Convolution についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by