How can I set xticklabels to an array?
Mostrar comentarios más antiguos
Hi,
I am trying to generate a plot and I need to set the x axis and y axis lables to some value I am calculating.
Initially I was hard coding them as strings but its not really convenient as every time I tune any parameter, I have to redo them. Is there a better way to do so?
noise = [0,1000,3000,5000,7000,9000,11000,13000];
snr=[];
for i=1:length(noise)
snr = [snr,10*log10((1000/noise(i))^2)];
end
% Need to set xlim as the calculated values in snr.
Currently I am doing something like this
p1 = plot(obj1(1,:)/30);
hold on;
p2 = plot(obj1(4,:)/30);
p3 = plot(obj1(5,:)/30);
p4 = plot(obj1(6,:)/30);
p5 = plot(baseline/30);
phandles = [p1 p2 p3 p4];
for h=1:length(phandles)
set(phandles(h),'LineWidth',3, 'LineStyle', linestyles{h}, 'MarkerSize', myMarkerSize, 'Marker', markers{h});
end
set(p5,'LineWidth',3, 'LineStyle', ':', 'MarkerSize', myMarkerSize,'Marker', 'x');
grid;
xlabel('SNR (dB)')
ylabel('PRR of ACK A');
ylim([0 1.1]);
xticklabels({'Inf','0','-9.54','-13.97','-16.90','-19.08','-20.82','-22.27'}) %need to use an array instead
leg = legend({'x4', 'x2.77', 'x2.04', 'x1','Baseline-A'},'Location','northeast');
leg.FontSize = 30;
title(leg,'Power Ratio (A:B)');
set(gca,'FontSize',myFontSize);
a = get(gca,'XTickLabel');
set(gca,'XTickLabel',a,'fontsize',20,'FontWeight','bold') %changes the font size of axis lables
If someone can point me towards how I can use an array to set xticklabels or yticklabels then it would be really helpful.
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Axis Labels en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!





