Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function [x, amntSigns] = FSKdecoder(signal, fstart, fend, Tsymbol, fs)
- % FSK Decoder made by group 8
- % fstart % transmission band frequency start
- % fend % transmission band frequency end
- % Tsymbol % symbol duration in seconds
- % fs % sampling frequency
- amntSigns = length(signal) / (Tsymbol*fs); % Finding symbol amount
- farray = round(linspace(fstart, fend, 256)); % 256 frequencies spread out in band
- freq = 1:amntSigns; % Preallocating space
- for i = 1:amntSigns % Find frequencies for each symbol in the signal
- decodeSignal = signal((i-1)*Tsymbol*fs+1:i*Tsymbol*fs); % Dividing the signal - isolating each symbol
- [~,maximum] = max(abs(fft(decodeSignal))); % Find the maximum of fft to find the frequency
- freq(i) = maximum / Tsymbol; % Converting to actual frequency
- end
- xDec = 1:amntSigns; % Preallocating space
- for i = 1:amntSigns % Find decimal value for ASCII character
- done = 0; % Register to check if frequency was found
- for n = 1:256 % Checking all frequencies in farray and compare to calculated freq
- if (farray(n) >= freq(i)) && (done == 0) % Finding the interval of frequencies & check if it's done already
- xDec(i) = n-1; % Assigning the decimal value (-1 because it's bigger than to find interval)
- done = 1; % Setting done - so we don't overwrite decimal value
- end
- end
- end
- x = char(xDec); % Output signal - converted to char
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement