Effacer les filtres
Effacer les filtres

Adding more x axis tick marks on graph

50 vues (au cours des 30 derniers jours)
JoshT_student
JoshT_student le 5 Oct 2018
Commenté : Star Strider le 5 Oct 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.

Réponse acceptée

Star Strider
Star Strider le 5 Oct 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 commentaires
JoshT_student
JoshT_student le 5 Oct 2018
Thank you Star Strider.
Star Strider
Star Strider le 5 Oct 2018
As always, my pleasure.

Connectez-vous pour commenter.

Plus de réponses (0)

Produits


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by