Remove NaNs during plotting (keep array the same length)

1 回表示 (過去 30 日間)
charles atlas
charles atlas 2014 年 7 月 29 日
回答済み: Azzi Abdelmalek 2014 年 7 月 29 日
Here is my issue: The Following code plots numbers as text on a Figure that already has points.
for k=1:length(temps)
sss=ss(k);
ht = text(tempx{k}, tempy{k}, num2str(sss),'Parent',ha);
end
The issue is that the array (ss) contains numbers and "NaNs" in it. The array is a 1X55 double that looks like this: ss = [1 5 3 8 3 9 NaN 0 3 5 NaN etc]
because of the fact that the elements of ss are matched with the elements in tempx and tempy, I cannot just remove the []'s.
Does anyone know how to plot ss paired with the tempx/tempy's but without the NaN's?
Appreciate it, Charles
  1 件のコメント
charles atlas
charles atlas 2014 年 7 月 29 日
Sorry, I meant to add that right before the code, I specify:
ha=axes;
- Charles

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

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2014 年 7 月 29 日
for k=1:length(temps)
sss=ss(k);
if ~isnan(sss)
ht = text(tempx{k}, tempy{k}, num2str(sss),'Parent',ha);
end
end

その他の回答 (1 件)

Robert Cumming
Robert Cumming 2014 年 7 月 29 日
Can you not just use isnan to check if its a nan
if ~isnan ( ss(k) )
% do your plotting?
end

カテゴリ

Help Center および File ExchangeTiming and presenting 2D and 3D stimuli についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by