How to combine multiple GF arrays into 1 big GF array

조회 수: 1 (최근 30일)
Nick
Nick 2022년 12월 1일
편집: Abhaya 2024년 12월 23일
Hi,
I am creating a Hamming(7,4) code and am holding the contents in a 1x7 gf array. The goal is to take a message such as "hello" (in 8 bits per character) turn it to binary and add the Hamming(7,4) code to it then combine it all back as one. The Hamming code can only do 4 bits at a time so it is returning a 1x7 GF array. For "hello" I obtain 10 1x7 GF arrays. Is there a way to combine these arrays into one big one GF array? Or make it a 2d array? So have an array hold each 1x7 cell array? Is there a way to append the 1x7 to the big array? I am new to MATLAB so I am not sure of all of the processes .
Thank you

답변 (1개)

Abhaya
Abhaya 2024년 12월 23일
편집: Abhaya 2024년 12월 23일
Hi Nick,
To combine multiple GF arrays either vertically or horizontally, you can use MATLAB's built-in functions. Here's how you can do it:
  • Vertical Concatenation: To concatenate multiple GF arrays vertically, you can use MATLAB ‘vertcatfunction.
Below is a simple example of concatenating multiple GF arrays vertically:
%Two gf arrays of size 1*7
gfArray1 = gf([1 0 1 1 0 0 1]);
gfArray2 = gf([0 1 1 0 1 1 0]);
% Vertically concatenate
combinedGFArrayV = vertcat(gfArray1, gfArray2);
% Display the result
disp(combinedGFArrayV);
2x7 gf array with properties: x: [2x7 uint32] m: 1 prim_poly: 3
  • Horizontal Concatenation: To concatenate multiple GF arrays horizontally, you can use MATLAB ‘horzcatfunction.
Below is an example of concatenating multiple GF arrays horizontally:
gfArray1 = gf([1 0 1 1 0 0 1]);
gfArray2 = gf([0 1 1 0 1 1 0]);
% Horizontally concatenate
combinedGFArrayH = horzcat(gfArray1, gfArray2);
% Display the result
disp(combinedGFArrayH);
1x14 gf array with properties: x: [1 0 1 1 0 0 1 0 1 1 0 1 1 0] m: 1 prim_poly: 3
For further information aboutvertcat’ and ‘horzcat, please follow the MATLAB documentations given below.
Hope this solves your query.

카테고리

Help CenterFile Exchange에서 Elementary Math에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by