How to skip many vectors in a legend?
6 次查看(过去 30 天)
显示 更早的评论
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';
0 个评论
采纳的回答
Paul
2022-10-11
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')
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Legend 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!