How do I fix my graph?

조회 수: 6 (최근 30일)
123fbyr765
123fbyr765 2018년 11월 29일
편집: Anusha Sridharan 2018년 12월 3일
I have a script which creates a few graphs based on calculations carried out. The graph looks very strange however. Once the graph finishes, it appears to go back to the start, so to speak. What can I do to stop this from happening? For example, I want the graph below to stop at ~(260,0) and not go back to ~(0,-900).
  댓글 수: 2
Bob Thompson
Bob Thompson 2018년 11월 29일
What is causing your dataset to generate the last value?
It would always be an option to simply leave off the last value from the range you are entering as your data set, but this is not a good option as you might lose track of valuable information.
Rena Berman
Rena Berman 2018년 12월 3일

(Answers Dev) Restored edit

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

답변 (1개)

Mark Sherstan
Mark Sherstan 2018년 11월 30일
편집: Mark Sherstan 2018년 11월 30일
Try the code below. Esentially I find the first instence when a value is greater than 260 and eliminate from that point to the end in both x and y vectors. You have to be careful with this as you could eliminate some data without meaning to so just make sure you are confident of your cutoff time (e.g. 260 in this case).
x = [0 100 150 200 250 300 0];
y = [0 500 1000 -500 -900 -300 -900];
figure(1); plot(x,y)
idx = find(x>260);
x(idx(1):end) = [];
y(idx(1):end) = [];
figure(2); plot(x,y)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by