Coding for different x-axis increments
7 ビュー (過去 30 日間)
古いコメントを表示
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');
0 件のコメント
回答 (2 件)
Star Strider
2019 年 11 月 25 日
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)
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!