Signaly
From RoboWiki
Signály
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % Takto sa kresli spektrum signalu typu Sinus s f 440 Hz. % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % f_sample = 8000; % [Hz] - pre telefony OK duration = 1; % [s] - jedna sekunda freq = 440; % [Hz] - komorne A4 = 440 Hz A = 0.9; % [V] - amplituda signalu z <-1,1> time = 0 : (1/f_sample) : duration; SinusSignal = A * sin( 2*pi*freq*time + 0 ); T_sample = 1/f_sample; N = length(SinusSignal); maxtime = (N-1) * T_sample; % Doba trvania signalu time = (0:N-1) * T_sample; % Casova osa freq = (0:N-1) / maxtime; % Kmitoctova osa % Fourierova analyza: S = fft(SinusSignal); % Vypocet komplexneho spektra Mod = 2/N * abs(S); % Spravne amplitudove spektrum Pha = 180/pi * angle(S); % Fazove spektrum v stupnoch N1 = round(N/2); % Kreslime len relevantu cast po f_sample/2 subplot(2,1,1); plot(freq(1:N1),Mod(1:N1)); % Aplitudova frekvencna charakteristika subplot(2,1,2); plot(freq(1:N1),Pha(1:N1)); % Fazova frekvencna charakteristika