plot by skipping some points

조회 수: 144 (최근 30일)
Babu Sankhi
Babu Sankhi 2021년 2월 1일
댓글: Babu Sankhi 2021년 2월 3일
Hi all,
I want to plot by skipping some points (4,31), (8, 71) and so on in my data . Is there any straight forward way of doing it?
Thank you
x=[1:1:20];
y=[1:10:200];
%x=c(:,1)
plot (x,y,'o');
%ismembertol(
  댓글 수: 2
Adam Danz
Adam Danz 2021년 2월 1일
편집: Adam Danz 2021년 2월 1일
It's unclear whether (4,41) and (8,81) in your example are indices or coordinates.
Neither of your vectors have 81 elements so they can't be indicies and the max value in "A" is 20 so that wouldn't work with coordinates as large as 40. So the example doesn't help either.
Babu Sankhi
Babu Sankhi 2021년 2월 2일
I am sorry about that I just want to plot by skipping some coordinates.

댓글을 달려면 로그인하십시오.

채택된 답변

Adam Danz
Adam Danz 2021년 2월 1일
편집: Adam Danz 2021년 2월 2일
Several methods to plot a subset of values within an array.
  1. Indexing. If you want to eliminate a list of (x,y) values, use functions like ismember, ismembertol, or == to create an index of matches, idx. Then use ~idx to select all other values when plotting plot(x(~idx), y(~idx)).
  2. Nan-replacement. After finding the values you want to ignore using indexing, replace those values with NaN. x(idx)=NaN; y(idx)=NaN; plot(x,y)
  3. Remove unwanted values. After finding the values you want to ignore using indexing, remove them using x(idx)=[]; y(idx)=[]; plot(x,y)
  4. To plot every n'th value: plot(x(1:n:end), y(1:n:end));
  5. To remove every n'th value: x(1:n:end)=[]; y(1:n:end)=[]; plot(x,y)
  6. To plot the n'th, m'th, and p'th values: idx=[n,m,p]; plot(x(idx),y(idx));
  7. To eliminate the n'th, m'th, and p'th values: idx=[n,m,p]; x(idx)=[]; y(idx)=[]; plot(x,y)
If you need additional help implementing any of those ideas, show us what you've tried where you're stuck.
  댓글 수: 3
Adam Danz
Adam Danz 2021년 2월 2일
편집: Adam Danz 2021년 2월 3일
> But ismember just gives the logical array which reapeats
Yes, that logical array can be used to select which values are plotted as shown in the first point in my answer. I don't know what you mean by "which repeats"
> in my case there is no repetition of y coordiantes on x!! so confused
I don't know what this means and it's still not clear to me how you'd like to select which values are plotted.
> I just want to plot by skipping some coordinate
Which coordinates? That's still to vague to suggest something specific. I've added methods 4,5,6,7 to my answer in case that's what you're looking for.
Babu Sankhi
Babu Sankhi 2021년 2월 3일
Thanks for your elaborative ideas.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by