From 259423ad3ff7dd7bd2ffde6640997768f923668e Mon Sep 17 00:00:00 2001 From: iridiumR Date: Thu, 28 Apr 2022 11:03:44 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9A=82=E4=B8=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Matlab/lab2.m | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 Matlab/lab2.m diff --git a/Matlab/lab2.m b/Matlab/lab2.m new file mode 100644 index 0000000..31ba27e --- /dev/null +++ b/Matlab/lab2.m @@ -0,0 +1,54 @@ +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);