2013-01-14 18 views
1

我必須做一個matlab程序,它應該創建一個QR碼。Matlab:我如何創建一個多項式發生器裏德所羅門的QR碼

我的問題是裏德 - 索羅門糾錯

用戶輸入他想要的字。 [...]我得到了一串數字,我應該在一個多項式發生器(裏德所羅門)(我發現一些網站,這樣做很好:http://www.pclviewer.com/rs2/calculator.html

我想它會發生:例如我輸入:32 91 11 120 209 114 220 77 67 64 236 17 236

[裏德所羅門生成多項式]

和我想找出:168 72 22 82 217 54 156 0 46 15 180 122 16

我發現了函數rsenc comm.rsencoder gf ...但是不可能理解這些函數的操作。功能詳細:http://www.mathworks.fr/fr/help/comm...n.html#fp12225

我嘗試這種類型的代碼:

n = 255; k = 13; % Codeword length and message length 
m = 8; % Number of bits in each symbol 
msg = [32 91 11 120 209 114 220 77 67 64 236 17 236]; % Message is a Galois array. 
obj = comm.RSEncoder(n, k); 
c1 = step(obj, msg(1,:)'); 
c = [c1].'; 

他生產的255串,而我想13的輸出。

謝謝你的幫助。

回答

0

我認爲你犯了一個錯誤。

'n'是帶校驗碼的最終消息的長度。 'K' 是信息的lenght(數字符號)

我想,這將幫助你:

clc, clear all; 
M = 16;  % Modulation Order || same that Max value, at your case: 256! 2^m 
hEnc = comm.RSEncoder; 
hEnc.CodewordLength = M - 1; % Max = M-1, Min = 4, Must be greater than MessageLenght 
hEnc.MessageLength = 13; % Experiment change up and down value (using odd number) 
hEnc.BitInput = false; 
hEnc 
t = hEnc.CodewordLength - hEnc.MessageLength; 
frame = 2*hEnc.MessageLength; % multiple of MensagemLength 
fprintf('\tError Detection (in Symbols): %d\n',t); 
fprintf('\tError Correction: %.2f\n',t/2); 
data = randi([0 M-1], frame, 1); % Create a frame with symbols range (0 to M-1) 
encodedData = step(hEnc, data); % encod the frame