This repository has been archived on 2024-01-06. You can view files and clone it, but cannot push or open issues or pull requests.
justhomework/Matlab/lab2.m

53 lines
814 B
Mathematica
Raw Normal View History

2022-04-28 03:03:44 +00:00
figure(1);
2022-05-05 12:25:46 +00:00
sy
2022-04-28 03:03:44 +00:00
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);