File: save_array_c_header.m

package info (click to toggle)
codec2 0.9.2-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 113,072 kB
  • sloc: ansic: 412,877; python: 4,004; sh: 1,540; objc: 817; asm: 683; makefile: 588
file content (14 lines) | stat: -rw-r--r-- 400 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
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 int %s[]={\n", array_name);
  for m=1:length(array)-1
    fprintf(f,"  %f,\n",array(m));
  endfor
  fprintf(f,"  %f\n};\n",array(length(array)));
  fclose(f);
endfunction