How to erase a data point in plotting

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

Abderrahim. B
Abderrahim. B 2022년 7월 18일
Hi!
What do you mean by ereas in plottinge?
You just do not want to see it on the plot!
Or you want to replace it with some value?
Or you wan to remove it from the data then plot ?
Emily
Emily 2022년 7월 18일
I would perfer to remove it from the data, then plot.
But if that's not possible, am ok with just not seeing it on the plot.
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
Star Strider 2022년 7월 18일
편집: Star Strider 2022년 7월 18일

0 개 추천

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’.
.

카테고리

도움말 센터File Exchange에서 Annotations에 대해 자세히 알아보기

태그

질문:

2022년 7월 18일

편집:

2022년 7월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by