How do I set axis ticks in a graph?

I followed the documentation but it's not working. I'm trying to set the ticks on the graph using xticks(), but Matlab says xticks is an undefined function or variable.
Here's my code:
firstnat = [ntfreq150_1, ntfreq175_1, ntfreq200_1, ntfreq225_1, ntfreq250_1];
secondnat = [ntfreq150_2, ntfreq175_2, ntfreq200_2, ntfreq225_2, ntfreq250_2];
Lvec = [150, 175, 200, 225, 250];
Xlabs = [Lvec];
Ylabs = [firstnat, secondnat]; Ylabs = sort(Ylabs); Ylabs = unique(Ylabs);
figure(14)
plot(Lvec, firstnat, 'g', Lvec, secondnat, 'b');
xticks(Xlabs)
yticks(Ylabs)
title('Natural Frequency vs. Length')
xlabel('Length of Beam (mm)')
ylabel('Natural Frequency (Hz)')
legend('First Natural Frequency', 'Second Natural Frequency', 'location', 'northwest')
grid on
firstnat, secondnat, and Lvec are all 1x5 arrays using data from earlier in the script.

Respuestas (1)

Sayan Saha
Sayan Saha el 11 de Mayo de 2018
Editada: Sayan Saha el 11 de Mayo de 2018

1 voto

According to the documentation of xticks the function was introduced in MATLAB version R2016b. If you are using a MATLAB version prior to that "xticks" will not work. Instead use the "XTick" property of the axes. For an example refer to:

Categorías

Más información sobre Axes Appearance en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 9 de Mayo de 2018

Editada:

el 11 de Mayo de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by