Marker indices for a plot error

조회 수: 22 (최근 30일)
Robert Scott
Robert Scott 2021년 8월 15일
댓글: Star Strider 2021년 8월 15일
So for whatever reason matlab will not allow me to make a marker index of less then 1. I get an error of
"Value must be a vector of positive integers."
I dont understand the problem. The plot has an x axis scale of very small numbers like .00001-.0001
So naturally my markers must be in that range.
Does anyone know why im getting this error?
plot(time_stamps,smooth(data(1:end,k)),'MarkerIndices',[.01])
  댓글 수: 1
Robert Scott
Robert Scott 2021년 8월 15일
If i make the marker index 1 the error goes away.

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

답변 (2개)

the cyclist
the cyclist 2021년 8월 15일
The MarkerIndices Name-Value pair is expecting the indices of the data points (e.g. the 1st, 5th, and 10th data point) to place the markers, not the values of those data points.
You might want to use the XTick property of the axes instead.
  댓글 수: 1
Robert Scott
Robert Scott 2021년 8월 15일
This is just rediculous.
Now xticks is telling me the indices must be increasing.
Who cares if they are increasing. All i want to do is put a "dot" on a point on a plot.
when thigns like min and max come back i have no idea if one index will be greater then the other.
Mathworks needs to significantly rethink the constraints on some of these elementry functions.

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


Star Strider
Star Strider 2021년 8월 15일
From the documentation on MarkerIndices:
Indices of data points at which to display markers, specified as a vector of positive integers
and 0.01 is not an integer.
.
  댓글 수: 4
Robert Scott
Robert Scott 2021년 8월 15일
편집: Robert Scott 2021년 8월 15일
and that is the issue, i dont know the index, i just no the x location I cant figure it out because the numbers im working with are very very small and im having a tuff time with truncating to do the math to figure out the actual index.
All i want to do is plot a point on a graph with an absolute X value and absolute y value
I also have tried to use create an x and y vector of the points i want to put a marker and plot that seperate but the issue is when i use plot twice once for the line and then again for the markers it overwrites it even with hold on
Your plot above works because you know the index.
I do not, i only know the absolute time
Star Strider
Star Strider 2021년 8월 15일
In that situation, and you want to put it at a x-value of 0.01, use interp1 and tthe x-values to find the y-values for the markers —
x = -0.5:0.13:2.5;
y = (x-1).^2;
figure
plot(x, y)
xp = 0.01;
yp = interp1(x, y, xp);
hold on
hp = plot(xp, yp, 'p');
hold off
hp.MarkerSize = 10;
hp.MarkerFaceColor = 'g';
grid
If you have the y-values and want to find the x-values, this becomes a bit more complicated, however otherwise straightforward.
.

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

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

태그

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by