Coding for different x-axis increments
Mostrar comentarios más antiguos
My code is as follows: How do I make it so the respective plots will have x-axis increments of 1.25 instead of 1?
g=[0 5 0 0 -10 100 -10 0 0 0 10 0 0 0 0 0];
N=16;
G=fft(g);
A=2*abs(G(1:9))/N;
phi=angle(G(1:9))*180/pi;
A(1)=abs(G(1))/N;
f=[0:1.25:10];
plot(f,A,f,A,'o');
xlabel('frequency (Hz)');
ylabel('amplitude A');
title('Amplitude of Fourier Transform');
figure
plot(f,phi,f,phi,'o');
xlabel('frequency (Hz)');
ylabel('phase (deg)');
title('Phase of Fourier Transform');
Respuestas (2)
Star Strider
el 25 de Nov. de 2019
Use the ‘f’ vector to define the 'XTick' locations:
set(gca, 'XTick',f)
Full code:
g=[0 5 0 0 -10 100 -10 0 0 0 10 0 0 0 0 0];
N=16;
G=fft(g);
A=2*abs(G(1:9))/N;
phi=angle(G(1:9))*180/pi;
A(1)=abs(G(1))/N;
f=[0:1.25:10];
plot(f,A,f,A,'o');
xlabel('frequency (Hz)');
ylabel('amplitude A');
title('Amplitude of Fourier Transform');
set(gca, 'XTick',f)
figure
plot(f,phi,f,phi,'o');
xlabel('frequency (Hz)');
ylabel('phase (deg)');
title('Phase of Fourier Transform');
set(gca, 'XTick',f)
Image Analyst
el 25 de Nov. de 2019
Use the xticks function:
xticks(f);
Categorías
Más información sobre Subplots 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!