# How to erase a data point in plotting

3 ビュー (過去 30 日間)
Emily 2022 年 7 月 18 日

Hi, there is a false data point at [500,0] that I want to remove
I thought of using
([500,0],:)=[]
but not quite sure how to get it working or if a different method is better.
%current plot
pline=plot([Trend]+231,[Trend.count]-Trend.mean, '-s')
##### 3 件のコメント表示 2 件の古いコメント非表示 2 件の古いコメント
Abderrahim. B 2022 年 7 月 18 日
To delete an element from an array use [ ].
A = [100 1 2 3 5 3 6 6] ;
plot(1:length(A), A, 'r') A(1) = []
A = 1×7
1 2 3 5 3 6 6
plot(1:length(A), A) サインインしてコメントする。

### 回答 (1 件)

Star Strider 2022 年 7 月 18 日

There are several ways to do this, the most obvious being —
x = 0 : 100: 1000; % Create Data — 'x' Is Actually 'Trend+231'
y = randn(size(x)); % Create Data — 'y' Is Actually 'Trend.count-Trend.mean'
y(6) = 0; % Create Data — Define Point
figure
plot(x, y, '.-') idx = find((x == 500) & (y == 0));
x(idx) = [];
y(idx) = [];
figure
plot(x, y, '.-') This assumes there could be several values at ‘x=500’ so it eliminates only the 0 value. If there is only one value at that point, it would only be necessary to test for ‘x==500’.
.

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

### カテゴリ

Find more on Graphics in Help Center and File Exchange

### Community Treasure Hunt

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

Start Hunting!