Remove line between first and last point on plot
이전 댓글 표시
I am plotting data from a text file, however, the plot automatically connects the first and last points. How do I get rid of this line?

data = load('data.txt');
time = data(:,1);
avg = data(:,2);
plot(time, avg)
채택된 답변
추가 답변 (1개)
Honglei Chen
2015년 7월 14일
Are you sure your last point and first point are not the same? If they are, simply do
plot(time(1:end-1),avg(1:end-1))
댓글 수: 2
manateejoe
2015년 7월 14일
Star Strider
2015년 7월 14일
See if:
time = [data(:,1); NaN];
avg = [data(:,2); NaN];
improves the plot.
If your data.txt file is not too large, attach it (use the ‘paperclip’ icon). Without it, it is only a guess as to what the best solution is.
카테고리
도움말 센터 및 File Exchange에서 Annotations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!