Is 'MarkerIndices' command available in any version of Matlab before 2016b by some other name or is there any similar function available in previous versions of Matlab?
7 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Soumya Dash
am 7 Okt. 2016
Kommentiert: Sreeraj T
am 15 Okt. 2020
Is 'MarkerIndices' command available in any version of Matlab before 2016b by some other name or is there any similar function available in previous versions of Matlab?
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 7 Okt. 2016
No, it is completely new as of R2016b. There was no previous functionality for it.
The work-around would be to plot twice:
MarkerIndices = [1 8 11 17 22] %for example
plot(x, y, 'b-'); %plot everything with appropriate line color and no marker
plot(x(MarkerIndices), y(MarkerIndices), 'b*'); %plot selectively with appropriate color and marker but no line
4 Kommentare
Steven Lord
am 24 Mär. 2017
Unless you explicitly tell legend which lines to include, yes the legend will include both lines.
x = 1:10;
y = x.^2;
lineToPlot = plot(x, y, 'k-');
hold on
lineNotToPlot = plot(x(1:3:end), y(1:3:end), 'ko');
legend(lineToPlot)
Compare this with:
x = 1:10;
y = x.^2;
lineToPlot = plot(x, y, 'k-');
hold on
lineNotToPlot = plot(x(1:3:end), y(1:3:end), 'ko');
legend show
Sreeraj T
am 15 Okt. 2020
Lets say that I have a command which goes like this:
x = 1:10;
y = x.^2;
lineToPlotA = plot(x, y, 'k-');
hold on
lineNotToPlotA = plot(x(1:3:end), y(1:3:end), 'ko');
legend('x and x^2')
hold on
lineToPlotB = plot(2*x, 2*y, 'k-');
hold on
lineNotToPlotB = plot(2*x(1:3:end), 2*y(1:3:end), 'ko');
legend('2x and 2x^2')
Here only the second legend is coming. What modification should i do to show the firsr legend also?
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Legend finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!