Thực hành matlab tín hiệu hệ thống

4 40 0
Thực hành matlab tín hiệu hệ thống

Đang tải... (xem toàn văn)

Thông tin tài liệu

Thực hành Tín hiệu và hệ thống Thực hành Tín hiệu và hệ thống sử dụng matlab|Ex1: Làm việc với ma trận A Tạo một vector gồm 100 giá trị cách đều nhau trong khoảng từ 50500. B Tạo một vector gồm các giá trị cách đều nhau trong khoảng từ 50500 với bước là 15. Tìm số phần tử của vector.

Thực hành Tín hiệu hệ thống | HQT-FoEEE-PU HƯỚNG DẪN LÀM BÀI TẬP: Ex1: Làm việc với ma trận A - Tạo vector gồm 100 giá trị cách khoảng từ 50-500 B - Tạo vector gồm giá trị cách khoảng từ 50-500 với bước 15 Tìm số phần tử vector Hướng dẫn: clear all; clc; % Tạo vector gồm 100 giá trị cách khoảng từ 50-500 X = linspace(50, 500); % -% Tạo vector gồm giá trị cách khoảng từ 50-500 với bước 15 % Tìm số phần tử vector Y = 50:15:500; n = length(Y); Ex2: Hãy tạo số phức x y Tìm giá trị phần thực, phần ảo, độ lớn, góc, pha, liên hợp phức, tích x y Sử dụng lệnh cart2pol pol2cart để chuyển đổi hệ tọa độ Hướng dẫn: clc;close all; clear; % clear matlab memory % Thao tac voi so phuc x = 3+4i % gan gia tri phuc cho x real(x) % phan thuc cua x imag(x) % phan ao cua x abs(x) % lon (magnitude)cua x = |x| angle(x) % goc pha cua x, tinh bang radian conj(x) % lien hop phuc cua x % Chuyen doi he z = -2 - j*3; % abs(z) % angle(z) % toa cuc - Descartes define complex number z=-2-j3 compute magnitude of complex number compute angle (in radians) of complex number angle(z)*180/pi % compute angle (in degrees) of complex number [anglez, magz] = cart2pol(real(z), imag(z)) % recompute magnitude and phase of complex number y = 3*exp(-j*pi/4)% define complex number y=3e^(-jpi/4) [realy, imagy] = pol2cart(-pi/4, 3) % determine real and imaginary parts of a complex number 3e^(-jpi/4) Thực hành Tín hiệu hệ thống | HQT-FoEEE-PU y*z % multiply complex numbers Ex3: Tạo tín hiệu x(t) = A.sin(ωt+φ) với ≤ t ≤ 10 Trong đó, A tháng sinh, ω = phần dư năm sinh chia tháng sinh, φ = ngày sinh clc;close all; clear; % clear matlab memory % Generation of a sinusoidal sequence n = 0:0.5:40; f = 0.9; phase = 0; A = 1.5; arg = 2*pi*f*n - phase; x = A*cos(arg); clf; % Clear old graph stem(n,x); % Plot the generated sequence axis([0 40 -2 2]); grid; title('Sinusoidal Sequence'); xlabel('Time index n'); ylabel('Amplitude'); axis; figure() plot(n,x); % Plot the generated sequence axis([0 40 -2 2]); grid; title('Sinusoidal Sequence'); xlabel('Time index n'); ylabel('Amplitude'); axis; Ex4: Tạo tín hiệu có giá trị ngẫu nhiên với ≤ t ≤ 100 Sử dụng hàm rand() clc;close all; clear; % clear matlab memory % Generation of a uniform random sequence n = 0:99; A = 2; rand('state',sum(100*clock)); % "seed" the generator % rand(1,100) is uniform in [0,1] % rand(1,100)-0.5 is uniform in [-0.5,0.5] % 4*(rand(1,100)-0.5) is uniform in [-2,2] x = 2*A*(rand(1,length(n))-0.5); % clf; % Clear old graph figure(1) stem(n,x); % Plot the generated sequence axis([0 length(n) -round(2*(A+0.5))/2 round(2*(A+0.5))/2]); grid; title('Uniform Random Sequence'); xlabel('Time index n'); ylabel('Amplitude'); axis; Thực hành Tín hiệu hệ thống | HQT-FoEEE-PU % bt1 ve ham e^-0.5t t=linspace(0,10,101); y=exp(-0.5*t); figure(2) plot(t,y,'k-.','LineWidth',3); xlabel('thoi gian - s') ylabel('do lon') title('ve ham suy hao') % script file: vidu.m % x = t.e(-t).cos(2.pi.t) khoang [0,8] t= linspace (0,8,500); x1= t.*exp(-t).*cos(2*pi*t); x2= t.*exp(-t).*sin(2*pi*t); x3= t.*exp(-t); x4= sin(2*pi*t); figure(3) subplot(221) plot (t,x1,'r'); subplot(222) plot (t,x2) subplot(223) plot (t,x3,'r'); subplot(224) plot (t,x4) xlabel ('thoi gian - s') ylabel ('do lon') title ('bai tap') %legend('x1','x2'); Thực hành Tín hiệu hệ thống | HQT-FoEEE-PU

Ngày đăng: 21/04/2023, 10:40

Tài liệu cùng người dùng

Tài liệu liên quan