MATLAB: Write data to header file

h

i have 1×800 double and i need to outpu in header file all this values like this; float sineTable[800] = { /* values go here */ };

Best Answer

How abou the following?
% Sample data
data = rand(1,800);
% Arrange it to comma-separated string
str = num2str(data);
str = regexprep(str,'\s+',',');
% Save as 'sample.h' file
fid = fopen('sample.h','w');
fprintf(fid,'sineTable[800] = {%s};\n',str);
fclose(fid);