55 lines
880 B
Mathematica
55 lines
880 B
Mathematica
|
figure(1);
|
||
|
Ts = 1/50;
|
||
|
t = 0:Ts:10-Ts;
|
||
|
x = sawtooth(t,0.5);
|
||
|
plot(t,x)
|
||
|
xlabel('Time (seconds)')
|
||
|
ylabel('Amplitude')
|
||
|
|
||
|
figure(2);
|
||
|
y = fft(x);
|
||
|
fs = 1/Ts;
|
||
|
f = (0:length(y)-1)*fs/length(y);
|
||
|
plot(f,abs(y))
|
||
|
xlabel('Frequency (Hz)')
|
||
|
ylabel('Magnitude')
|
||
|
title('Magnitude')
|
||
|
|
||
|
figure(3);
|
||
|
Ts = 1/50;
|
||
|
t = 0:Ts:10-Ts;
|
||
|
x = exp(-3*t);
|
||
|
plot(t,x)
|
||
|
xlabel('Time (seconds)')
|
||
|
ylabel('Amplitude')
|
||
|
|
||
|
figure(4);
|
||
|
y = fft(x);
|
||
|
fs = 1/Ts;
|
||
|
f = (0:length(y)-1)*fs/length(y);
|
||
|
plot(f,abs(y))
|
||
|
xlabel('Frequency (Hz)')
|
||
|
ylabel('Magnitude')
|
||
|
title('Magnitude')
|
||
|
|
||
|
|
||
|
figure(5);
|
||
|
syms w t;
|
||
|
X=w*sin(3/2*w)*2/3;
|
||
|
subplot(2,2,1);
|
||
|
ezplot(X,[-10,10]);
|
||
|
iX=ifourier(F,t);
|
||
|
subplot(2,2,2);
|
||
|
ezplot(iX,[-10,10]);
|
||
|
subplot(2,2,3);
|
||
|
ezplot(abs(X),[-10,10]);
|
||
|
im=imag(X);
|
||
|
re=real(X);
|
||
|
phase=atan(im/re);
|
||
|
subplot(2,2,4);
|
||
|
ezplot(phase,[-10,10]);
|
||
|
|
||
|
figure(6);
|
||
|
[H,W]=freqs([1,-1],[1,1]);
|
||
|
plot(abs(W),H);
|