Difference between revisions of "Signály"
From RoboWiki
(→Prírodné signály) |
|||
Line 153: | Line 153: | ||
Môžete si ich stiahnuť a robiť s nimi neskôr pokusy. Časom snáď pribudnú ďalšie a lepšie. | Môžete si ich stiahnuť a robiť s nimi neskôr pokusy. Časom snáď pribudnú ďalšie a lepšie. | ||
− | gallery> | + | <gallery> |
Image:SignalHeart.png|[[Media:heart.m|Srdce - EKG]][[Image:Mfile_icon.png]] | Image:SignalHeart.png|[[Media:heart.m|Srdce - EKG]][[Image:Mfile_icon.png]] | ||
Image:SignalTemp.png|[[Media:teplota.m|Teplota vzduchu]][[Image:Mfile_icon.png]] | Image:SignalTemp.png|[[Media:teplota.m|Teplota vzduchu]][[Image:Mfile_icon.png]] |
Revision as of 13:51, 19 June 2008
Budeme sa zaoberať nasledovnými typmi signálov:
- umelé,
- prírodné,
- audio,
- video.
Umelé testovacie signály
Na testovanie sa používajú umelé signály
- impulz
- skok
- harmonický signál
- šum
% Uvedene signaly v Octave vyrobime takto
PulseSignal = zeros(1000,1); PulseSignal(5)=1;
StepSignal = zeros(1000,1); StepSignal(6:50)=1;
SinusSignal = sin(linspace(0,4*pi,100));
NoiseSignal = 0 + 0.6 * randn([100 1]); % \mu = 0, \sigma = 0.6
HeartSignal;
% A vsetky naraz nakreslime. Po skonceni skriptu mame signaly
% nachystane v pamati. Mozeme ich dalej pouzivat.
%
clg; figure(1);
subplot(5,1,1);
stem(PulseSignal); axis ([0 100 -0.5 1.5]);
subplot(5,1,2);
stem(StepSignal,"b"); axis ([0 100 -0.5 1.5]);
subplot(5,1,3);
plot(SinusSignal,"g"); axis([0 100 -1.5 1.5]);
subplot(5,1,4);
plot(NoiseSignal,"r"); axis([0 100 -1.5 1.5]);
subplot(5,1,5);
plot(heart(:,1),heart(:,2)); axis([0 5 -1 2]);
Download
Toto nefunguje (a asi ani nebude): http://virtuallab.kar.elf.stuba.sk/robowiki/images/5/52/Mfile_icon.png signaly.m
Po stiahnutí si súbor uložte ako signaly.m a v Octave napíšte demo signaly.
Harmonické signály
V nasledujúcom príklade vytvoríme v Matlabe/Octave harmonický signál a jeho rôzne kombinácie.
% Priklad na vytvaranie harmonickych signalov
%
% Okrem vykreslovania mozeme spravit export do .wav suboru a potom
% si vysledne zvuky prehravat a prezerat napriklad v Audacity
%
% (c) Richard Balogh, 30. 5. 2008
%
%
%
% %%%%%%%%%%%%% Signal 1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
f_sample = 8000; % [Hz] - pre telefony OK
duration = 1; % [s] - jedna sekunda
time = 0 : (1/f_sample) : duration;
% time = linspace(0,duration,f_sample); % Alternativa zapisu
freq = 440; % Komorne A4 = 440 Hz
A = 0.9; % Amplituda je z intervalu <-1,1>
fi = 0; % Fazovy posun
A4 = A * sin(2*pi*freq*time + fi);
% plot(A4); % Mozeme si aj nakreslit
wavwrite(A4',"sinusA4_8k.wav"); % A4' - wavwrite potrebuje stlpec
% %%%%%%%%%%%%% Signal 2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
A = 1.9; % To iste, ale zvacsime apmplitudu
A4 = A * sin(2*pi*freq*time);
wavwrite(A4',"sinusA4_8k_orez.wav"); % Orezany signal, ma vyssie harmonicke
% %%%%%%%%%%%%% Signal 3 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
f_sample = 44100; % [Hz] - CD audio
duration = 1; % [s] - jedna sekunda
time = 0 : (1/f_sample) : duration;
freq = 440; % Komorne A4 = 440 Hz
A = 0.9; % Vratime zasa naspat
A4 = A * sin(2*pi*freq*time);
wavwrite(A4',f_sample,16,"sinusA4_44k.wav"); % Musime zadat, ak f_sample != 8k
% %%%%%%%%%%%%% Signal 4 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Akord A4 + C5# + E5
% A4 = 440 Hz
% C5# = 554,37
% E5 = 659,26
% http://www.phy.mtu.edu/~suits/notefreqs.html
%
A4 = A * sin(2*pi*440.00*time);
Cis5 = A * sin(2*pi*554.37*time);
E5 = A * sin(2*pi*659.26*time);
Tone = (A4 + Cis5 + E5)/3; % Aby amplituda bola <-1,1>
wavwrite(Tone',f_sample,16,"chordA4_44k.wav");
% %%%%%%%%%%%%% Signal 5 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Pridame k tonu sumovu zlozku
%
noise = 0 + 0.2 * randn(size(time)); % \mu = 0, \sigma = 0.2
Tone = (A4 + noise)/2; % Aby amplituda bola <-1,1>
wavwrite(Tone',f_sample,16,"noiseA4_44k.wav");
Download
Prírodné signály
Týmto neohrabaným názvom označujem signály, ktoré pochádzajú z reálneho sveta, nie z počítačovej simulácie. Môžete si ich stiahnuť a robiť s nimi neskôr pokusy. Časom snáď pribudnú ďalšie a lepšie.