masking data plots for graph
20 ビュー (過去 30 日間)
古いコメントを表示
I want my plot to include my mask:
mask=true(size(x));
mask(0>x)=false;
mask=true(size(y));
mask(0>y)=false;
plot(x(mask),y(mask),'.')
It is not a problem, when I only have to mask the x values or y values seperately, only when I have to plot both masks.
Could the problem be that my mask for x and y respectively aren't having a particular definition? I tried with 'xmask' and 'ymask' and add this to the plotting sequence, but it does not work either.
0 件のコメント
回答 (2 件)
Walter Roberson
2017 年 11 月 18 日
xt = x;
xt(xt<0) = nan;
yt = y;
yt(yt<0) = nan;
plot(xt, yt);
3 件のコメント
Walter Roberson
2017 年 11 月 18 日
mask = (x > 0) & (y > 0);
[b,stats]=robustfit(x(mask),y(mask));
However, this is only going to work if x and y are vectors. If they are 2D then the result of x(mask) and y(mask) is going to be a column vector, because 2D arrays cannot have "holes" in them.
参考
カテゴリ
Help Center および File Exchange で Author Block Masks についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!