How do I fix my graph?
조회 수: 6 (최근 30일)
이전 댓글 표시
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
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.
답변 (1개)
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)
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!