How to combine multiple GF arrays into 1 big GF array
Ältere Kommentare anzeigen
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
Antworten (1)
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 ‘vertcat’ function.
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);
- Horizontal Concatenation: To concatenate multiple GF arrays horizontally, you can use MATLAB ‘horzcat’ function.
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);
For further information about ‘vertcat’ and ‘horzcat’, please follow the MATLAB documentations given below.
Hope this solves your query.
Kategorien
Mehr zu Data Types finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!