plotting a vertical line in matlab?

조회 수: 7 (최근 30일)
Sarah
Sarah 2012년 4월 18일
Hey guys,
I am trying to plot a vertical line in matlab. i need to be able to change its thickness and its color. I will be plotting several vertical lines. I need to plot it at a specific point on the x-axis, and it needs to extend vertically in both directions.
Here is what I have so far:
figure;
clf;
plot(TimeNum,AirTemp1,'k.','LineWidth',1.2);
datetick('x','HH:MM:SS');
xlabel('Time'); ylabel('Temp. (deg-C)'); grid on;
line([x(668) x(668)],[-3.2 -2.8]);
set(gca,'YLim',[-3.2 -2.8])
I dont know why, but my line doesn't show up. Any help would be much appreciated!
  댓글 수: 1
Sarah
Sarah 2012년 4월 18일
oh sorry, i almost forgot, here is the error notice:
??? Undefined function or method 'x' for input arguments of type
'double'.

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

답변 (2개)

Geoff
Geoff 2012년 4월 18일
As the error says, you don't have a variable called x and so you can't ask for the 668th element.
You might mean this:
line([668 668],[-3.2 -2.8]);

Walter Roberson
Walter Roberson 2012년 4월 18일
Your code
line([x(668) x(668)],[-3.2 -2.8]);
is fine. Just add appropriate options like 'LineWidth' and 'Color'.

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by