How to skip many vectors in a legend?
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I'm trying to plot a lot of sumulation results in the background of a graph as reference. Then, I try to show just the average and the theoretical results for comparison, but I don't know how to avoid the 500 vectors to show just three elements because in the legend the code corresponds just to the many vectors.
I can't change the order because the average and analytical results underlap the simulation results.
The bottom image corresponds to the correct code for the legend.
And this is the code for the graph.
subplot(3,2,1)
plot(tau,RZcZc,'Color',[0.5 0.7 1],'LineWidth',0.5)
hold on
plot(tau,RZcZc_av,'LineWidth',3)
plot(tau,RZcZc_theory,'k','LineWidth',3)
title(['Autocorrelation ', '$R_{Z_{c}Z_{c}}$'],'interpreter','latex')
ylabel('Autocorrelation')
xlabel(['Normalized time ', '($f_d \tau$)'],'interpreter','latex')
legend('Simultion','Average','Analytical')
ax = gca;
ax.FontSize = 12;
ax.FontName = 'Helvetica';
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1152998/image.jpeg)
0 comentarios
Respuesta aceptada
Paul
el 11 de Oct. de 2022
Something like this, but with different data
simulation = rand(100,20);
average = mean(simulation,2);
analytical = 0*average+0.5;
figure
hold on
hsim = plot(1:100,simulation,'r');
havg = plot(1:100,average,'b');
hana = plot(1:100,analytical,'k');
legend([hsim(1) havg hana],'Simulation','Average','Analytical')
Más respuestas (0)
Ver también
Categorías
Más información sobre Legend en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!