Adding more x axis tick marks on graph

63 Ansichten (letzte 30 Tage)
JoshT_student
JoshT_student am 5 Okt. 2018
Kommentiert: Star Strider am 5 Okt. 2018
Hello. I am trying to add more x axis ticks marks on my graph. My frequency (x values) are going from 5000 to 50,000, so it would be nice to have a tick mark with the number from the beginning at 5,000 and then it increments by 5000. I tried using the xticks code but it did not work. The code I have is below, you'll see that I only have one label at the moment, which is not good.
c=0.022*10^(-6);
frequency = 5000:5000:50000;
omega = 2.*pi.*frequency;
transfer = ((omega.*300.*c)./sqrt(1+(omega.*300.*c).^2)).*(1./sqrt(1+(omega.*220.*c).^2));
HN=20.*log10(transfer);
figure
semilogx(frequency, HN);
xlabel('frequency (Hz) in log scale');
ylabel('transfer function');
title('transfer function vs. frequency in log scale');
Thank you for the help.

Akzeptierte Antwort

Star Strider
Star Strider am 5 Okt. 2018
Try this:
c=0.022E-6;
frequency = 5000:5000:50000;
omega = 2.*pi.*frequency;
transfer = ((omega.*300.*c)./sqrt(1+(omega.*300.*c).^2)).*(1./sqrt(1+(omega.*220.*c).^2));
HN=20.*log10(transfer);
figure
semilogx(frequency, HN);
xlabel('frequency (Hz) in log scale');
ylabel('transfer function');
title('transfer function vs. frequency in log scale');
Ax = gca;
set(gca, 'XTick', frequency, 'XTickLabelRotation', 30)
  2 Kommentare
JoshT_student
JoshT_student am 5 Okt. 2018
Thank you Star Strider.
Star Strider
Star Strider am 5 Okt. 2018
As always, my pleasure.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Produkte


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by