Why does calling the legend function with multiple outputs throw a warning in MATLAB R2024b?
Ältere Kommentare anzeigen
When I use the "legend" function in MATLAB R2024b, I encounter the below warning:
Warning: Calling legend with multiple outputs will not be supported in a future release
I see this after running the following script:
figure; hold on;
x = linspace(0, 2*pi, 200);
p(1) = plot(x, sin(x), 'LineWidth', 1);
p(2) = plot(x, cos(x), 'LineWidth', 1);
p(3) = plot(x, sin(2*x), 'LineWidth', 1);
hold off
[~, legObjs] = legend(p, {'Sine', 'Cosine', 'Sin 2x'}, 'Location', 'best');
Why does this warning occur and how should I use the "legend" function to avoid this issue while maintaining current functionality?
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Legend 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!