aboutsummaryrefslogtreecommitdiff
path: root/octave/save_array_c_header.m
diff options
context:
space:
mode:
Diffstat (limited to 'octave/save_array_c_header.m')
-rw-r--r--octave/save_array_c_header.m14
1 files changed, 14 insertions, 0 deletions
diff --git a/octave/save_array_c_header.m b/octave/save_array_c_header.m
new file mode 100644
index 0000000..1fd87bb
--- /dev/null
+++ b/octave/save_array_c_header.m
@@ -0,0 +1,14 @@
+% save_array_c_header.m
+%
+% David Rowe Sep 2015
+
+function save_array_c_header(array, array_name, filename)
+ f=fopen(filename,"wt");
+ fprintf(f,"/* Generated by save_array_c_header.m Octave function */\n\n");
+ fprintf(f,"const float %s[]={\n", array_name);
+ for m=1:length(array)-1
+ fprintf(f," % .16f,\n",array(m));
+ endfor
+ fprintf(f," % .16f\n};\n",array(length(array)));
+ fclose(f);
+endfunction