change x axis, i have a plot of data from a headset. then i have 5 lines from a game, so i want 0-time from start(green) line till the end(red line), is it possible?
이전 댓글 표시
plot(data(2:end,3),data(2:end,1));
hold on;
plot(data(2:end,3),data(2:end,2), 'k');
plot([Start Start],[0 1], 'g');
plot([mistake1 mistake1],[0 1], 'c');
plot([mistake2 mistake2],[0 1], 'c');
plot([mistake3 mistake3],[0 1], 'c');
plot([mistake4 mistake4],[0 1], 'c');
plot([End End],[0 1], 'r');

채택된 답변
추가 답변 (1개)
Michael Haderlein
2015년 4월 29일
편집: Michael Haderlein
2015년 4월 29일
It's not quite clear what you want.
1) You want the x-axis to only go from the green line to the red line:
xlim(Start, End)
as you have named the respective values this way.
2) You want to get the data which lies in between the green and the red line for further processing:
partofthedata=data(data(:,3)>=Start & data(:,3)<=End,:);
Please note that the exclusion of the first row (you use data(2:end,...)) is not applied here. If this is a problem, first remove this row and then cut out the way I have shown here.
3) A comment on your variable naming: "End" is a very bad variable name. First, it's a keyword and second it has a special meaning as index (even though you have capitalized it - I wouldn't use it).
댓글 수: 3
sindre Røyland
2015년 4월 29일
pfb
2015년 4월 29일
xlim(Start, End)
would produce an error, though. The limits should be in a vector, at least up to R2012b.
xlim([Start, End])
I agree on avoiding the name End for a variable. Did not spot that.
Michael Haderlein
2015년 5월 4일
Oops, thanks for correcting me. Of course it's supposed to be an array. Anyway, guess the issue is already solved.
카테고리
도움말 센터 및 File Exchange에서 Graphics Object Properties에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!