MATLAB: How to save a Galois Field array to a file in MATLAB 7.8( R2009a)

Communications ToolboxfwritegfMATLAB

I have created a Galois Field array using the GF command in Communication Toolbox 4.3 (R2009a). I want to write this array to a file using FWRITE. When I try to write it using the following MATLAB code:
x = 0:3;
m = 2;
a = gf(x,m);
fid=fopen('output1.txt','w');
fwrite(fid,a,'ubit1');
fclose(fid);
I get an error message:
??? Error using ==> fwrite
Cannot write value: unsupported class gf

Best Answer

The ability to directly write a Galois Field array to a file is not supported in MATLAB 4.3 (R2009a).
In order to write a galois field array, one needs to convert the GF object to a double and then write to a file. For instance:
x = 0:3;
m = 2;
a = gf(x,m);
a_new =double(a.x);
fid=fopen('output1.txt','w');
fwrite(fid,a_new,'ubit1');
fclose(fid);