matlab 如何更改不同子情节的图例字符串?

qyswt5oh  于 2022-11-24  发布在  Matlab
关注(0)|答案(1)|浏览(139)

我想为每个子情节添加一个图例,如下所示

每个图例都是theta_(1/2)=5, theta_(1/2)= 10, theta_(1/2)=15,...,theta_(1/2)=60。如何更改每个图例的编号?

Q = [16,32,64,128,256,512,1024];

VEC_Beam_5 = [113.2659   69.7204   51.8739   34.5033   21.6538   10.9459    5.9488];   % Coverage area of Theta = 5
VEC_Beam_10 = [117.5491   76.1452   53.3016   38.3105   23.0815   13.5634    6.9007];  % Coverage area of Theta = 10
VEC_Beam_15 = [117.5491   76.1452   53.3016   38.3105   23.0815   13.5634    6.9007];  % Coverage area of Theta = 15
VEC_Beam_20 = [117.7870   76.1452   53.3016   38.5485   23.0815   13.5634    6.9007];  % Coverage area of Theta = 20
VEC_Beam_25 = [117.7870   76.6211   54.2534   38.5485   23.0815   13.5634    6.9007];  % Coverage area of Theta = 25
VEC_Beam_30 = [117.7870   76.6211   54.2534   38.5485   23.0815   13.5634    6.9007];  % Coverage area of Theta = 30
VEC_Beam_35 = [117.7870   76.6211   54.2534   38.5485   23.0815   13.5634    6.9007];  % Coverage area of Theta = 35
VEC_Beam_40 = [117.7870   76.6211   54.2534   38.5485   23.0815   13.5634    6.9007];  % Coverage area of Theta = 40
VEC_Beam_45 = [117.7870   76.6211   54.2534   38.7864   23.0815   13.5634    6.9007];  % Coverage area of Theta = 45
VEC_Beam_50 = [117.7870   76.6211   54.2534   38.7864   23.0815   13.5634    6.9007];  % Coverage area of Theta = 50
VEC_Beam_55 = [117.7870   76.6211   54.2534   38.7864   23.0815   13.5634    6.9007];  % Coverage area of Theta = 55
VEC_Beam_60 = [117.7870   76.6211   54.2534   38.7864   23.0815   13.5634    6.9007];  % Coverage area of Theta = 60

VEC_Beam = [VEC_Beam_5;VEC_Beam_10;VEC_Beam_15;VEC_Beam_20;VEC_Beam_25;VEC_Beam_30;VEC_Beam_35;VEC_Beam_40;VEC_Beam_45;VEC_Beam_50;VEC_Beam_55;VEC_Beam_60];
figure

cmap = jet(12);

for k1 = 1:12
    subplot(2,6,k1);
    plot(log2(Q),VEC_Beam(k1,:), 'Color', cmap(k1, :),'LineWidth',2, 'Marker','O');
    xticks(log2(Q))
    xticklabels(string(Q))
    xlabel('Q');
    ylabel('Coverage area');
    grid on;
end

sgtitle('QAM 16');
v7pvogib

v7pvogib1#

只需在循环中修改字符串即可。我建议使用sprintf()来明确说明:

for ii = 1:12
    % your plot
    legend_str = sprintf('\\theta_(1/2) = %d\\circ', 5 * ii)
    legend(legend_str)
end

感谢Sardar Usama对LaTeX的修正。

相关问题