Filter löschen
Filter löschen

How to skip many vectors in a legend?

2 Ansichten (letzte 30 Tage)
Karla
Karla am 11 Okt. 2022
Kommentiert: Karla am 12 Okt. 2022
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';

Akzeptierte Antwort

Paul
Paul am 11 Okt. 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')

Weitere Antworten (0)

Tags

Produkte


Version

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by