필터 지우기
필터 지우기

Plotting only SOME of the points on a curve

조회 수: 4 (최근 30일)
arvind ramasamy
arvind ramasamy 2017년 12월 6일
답변: Image Analyst 2017년 12월 18일
I plot a voltage (12.4 to 10.8) over time from a instrument. Now i want to introduce markers only at the set points where it changes. So how to introduce the markers for it.
plot(Test1.U_Batt, 'o-', 'linewidth',0.5, 'markersize',5, 'markerfacecolor','g')
I used this command and it showed all the points in the curve. But I want them to show for only some of the points.
Can any one help me out???

답변 (2개)

Benjamin Kraus
Benjamin Kraus 2017년 12월 6일
편집: Benjamin Kraus 2017년 12월 6일
What version of MATLAB are you using? There is a new feature, introduced in R2016b that allows you to specify which vertices in a line to mark. Look on the Line Properties doc page for the MarkerIndices property.
The example in the R2016b Release Notes looks like this:
x = linspace(0,10,500);
y = sin(x);
plot(x,y,'-o','MarkerIndices',1:10:length(y))
If you are using an older version of MATLAB, the only solution is to plot two different lines:
  1. One line that has no markers but includes all the data points.
  2. A second line that has no line style, has a marker, but only includes the points you want to mark.

Image Analyst
Image Analyst 2017년 12월 18일
Just pass in the indexes that you want to plot
y = Test1.U_Batt;
plot(y(desiredIndexes), 'o-', 'LineWidth',0.5, 'MarkerSize',5, 'MarkerFaceColor','g')

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by