save_plot

Digital Signal Processing Library

Voice Lab

Program name: save_plot

Language: C

In file: file_lib.c

Objective: Write plot info to file.

Usage: void save_plot(double **matrix, int order, int num_vectors, char *file_name, int options);

Parameters:

  • matrix - list of vectors to plot.
  • order - width of vectors.
  • num_vectors - number of vectors in list
  • file_name - name of file to open and plot vectors to
  • options -
Return:
  • void

Mathematical Description:

Comments: Routine is used to save vectors in a format that gnuplot can read and plot

User Comments

Code:

void save_plot(double **matrix, int order, int num_vectors, char *file_name, int options)
{
int i, j, offset;
FILE *out_file;

if((out_file = fopen(file_name,"w")) == NULL) {
fprintf(stderr, "Cannot open output file: %s\n", file_name);
exit(1);
}

offset = 0x01 & options;

for(i = 0; i < num_vectors; i++) {
for(j = offset; j < (order + offset); j++) {
fprintf(out_file, "%d, %d, %f\n", j, i, matrix[i][j]);
}
fprintf(out_file, "\n");
}
fclose(out_file);
}