Marker indices for a plot error
Ältere Kommentare anzeigen
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 Kommentar
Robert Scott
am 15 Aug. 2021
Antworten (2)
the cyclist
am 15 Aug. 2021
0 Stimmen
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 Kommentar
Robert Scott
am 15 Aug. 2021
Star Strider
am 15 Aug. 2021
0 Stimmen
‘Indices of data points at which to display markers, specified as a vector of positive integers’
and 0.01 is not an integer.
.
4 Kommentare
Robert Scott
am 15 Aug. 2021
I will not argue with you about the MATLAB definitions.
x = 0:0.1:2;
y = (x-1).^2;
figure
hp = plot(x, y, 'p-');
hp.MarkerIndices = 15;
hp.MarkerSize = 10;
hp.MarkerFaceColor = 'g';
grid
.
Robert Scott
am 15 Aug. 2021
Bearbeitet: Robert Scott
am 15 Aug. 2021
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.
.
Kategorien
Mehr zu Annotations finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

