필터 지우기
필터 지우기

How to remove unwanted X from Xdata

조회 수: 2 (최근 30일)
Joel Sande
Joel Sande 2015년 7월 16일
답변: dpb 2015년 7월 16일
A1=[0 0.5 1 1.3 1.7 2 2.3 2.7 3 3.3 3.7 4 4.3 4.7 5];
B1=[0.25 0.5 1 2 3 4 4.5 5 4.5 4 3 2 1 0.5 0.25];
figure;
subplot(2,1,1);
plot(A1,B1);
h = findobj(gca,'Type','line');
x = get(h,'Xdata');
y = get(h,'Ydata');
A2=[0 0.5 1 1.3 1.7 2 2.3 2.7 3 3.3 3.7 4 4.3 4.7 5 6 7 8 9];
B2=[0.25 0.5 1 2 3 4 4.5 5 4.5 4 3 2 1 0.5 0.25 0.2 0.15 0.1 0.1];
subplot(2,1,2);
plot(A2,B2);
h2 = findobj(gca,'Type','line');
x2 = get(h2,'Xdata');
y2 = get(h2,'Ydata');
% How can I remove the (x2,y2 data) were y2 < 0.25 ? to get the same result as above
% In other word, in my Xdata, I don't want X after 5 because of the small value of Y
---
Thanks

채택된 답변

dpb
dpb 2015년 7월 16일
idx=find(B2>=0.25,1,'last');
plot(A2(1:idx),B2(1:idx))

추가 답변 (1개)

Azzi Abdelmalek
Azzi Abdelmalek 2015년 7월 16일
idx=y2<0.25;
y2(idx)=[];
x2(idx)=[]

카테고리

Help CenterFile Exchange에서 Visual Exploration에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by