what is wrong with the 'gf' function in 'bchenc' and 'bchdec'?

4 vues (au cours des 30 derniers jours)
Siheng Liu
Siheng Liu le 21 Juin 2022
Commenté : Walter Roberson le 27 Oct 2023
I want to encode and modulate a figure and recover it through (15,7) BCH code.
The bchdec function requires a GF input code, so I use 'demodsig = gf(demodsig);' to transmit it to gf matrix.
However, the gf function stuck. This programme can't run, nor stop.
% ------------- show figure ---------------
A=imread('test.jpg');
A_shrunk = imresize(A,0.2); % we’ll reduce the resolution, as otherwise the file size is too large
% imshow(A_shrunk) % displays the shrunken image
% size(A_shrunk)% we get the figure is 318*566*3
Bs = reshape(A_shrunk,[318*566*3,1,1]); % resizes this image from a pixel array of three colours to a one-dimensional data stream
C = de2bi(double(Bs)); % converts these values to binary representation
%----------- mod -----------
C1 = C(:)';
M = 2;
n = 15;
k = 7;
C0 = zeros(1,2);
CC = [C1,C0];
CC = reshape(CC,617102,k);
msg = gf(CC);
code = bchenc(msg, n, k);
txpsk = pskmod(double(code.x),M);
% scatterplot(txpsk);
% title('Noisy PSK Scatter Plot')
%----------- demode ---------
SNR = 5;
out = awgn(txpsk,SNR);% set the SNR
demodsig = pskdemod(out,M);
% ------------------------Here is the problem------------------
demodsig = gf(demodsig);
decodsig = bchdec(demodsig, n, k);
decodsig(4319714) = [];
decodsig(4319713) = [];
Re = reshape(decodsig,[318*566*3,8]);
BS_rec = uint8(bi2de(Re)); % convert bits to pixel values.
A_rec = reshape(BS_rec,[318,566,3]); % reshape back to a coloured pixel array.
imshow(A_rec) % display the recovered image.
%---------calculate the BER ----------
err = length(find(decodsig~=C1));
BER = err/length(C1);
BER_theory = qfunc(sqrt(2*SNR));

Réponses (1)

Shivam
Shivam le 27 Oct 2023
Hi Siheng,
I understand that on executing the following line of the given code looks like a pause to you.
decodsig = bchdec(demodsig, n, k);
You can check the size of "demodsig" array to be 617102*15. When you call the "bchdec" function with this large array, MATLAB indicates it is "Busy" in the lower-left corner of MATLAB because the implementation of the "bchdec" function iterates 617102 times. Roughly, it takes 10 minutes for 1 lac iterations and possibly will take more than an hour to finish execution. Because of this, it might give you the impression of a pause in the code.
Also, the "Busy" status signifies that MATLAB is currently processing, not paused. The code execution will proceed once "bchdec" completes its execution.
You can refer to the following documentation to know more about the "Galois Field Array(gf)" and "bchdec" function:
I hope this helps.
Thanks.
  1 commentaire
Walter Roberson
Walter Roberson le 27 Oct 2023
(Note: "1 lac", also written "1 lahk", is "100,000")

Connectez-vous pour commenter.

Catégories

En savoir plus sur Error Detection and Correction dans Help Center et File Exchange

Produits


Version

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by