matlab.c
上传用户:aoeyumen
上传日期:2007-01-06
资源大小:3329k
文件大小:1k
源码类别:

DVD

开发平台:

Unix_Linux

  1. /*
  2.  *
  3.  *  matlab.c
  4.  *
  5.  * Copyright (C) Aaron Holtzman - May 1999
  6.  *
  7.  *  This file is part of ac3dec, a free Dolby AC-3 stream decoder.
  8.  *
  9.  *  ac3dec is free software; you can redistribute it and/or modify
  10.  *  it under the terms of the GNU General Public License as published by
  11.  *  the Free Software Foundation; either version 2, or (at your option)
  12.  *  any later version.
  13.  *   
  14.  *  ac3dec is distributed in the hope that it will be useful,
  15.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  16.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17.  *  GNU General Public License for more details.
  18.  *   
  19.  *  You should have received a copy of the GNU General Public License
  20.  *  along with GNU Make; see the file COPYING.  If not, write to
  21.  *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 
  22.  *
  23.  *
  24.  */
  25. #include <stdio.h>
  26. #include <stdlib.h>
  27. #include "matlab.h"
  28. matlab_file_t *matlab_open(char name[])
  29. {
  30. matlab_file_t *mf;
  31. mf = malloc(sizeof(matlab_file_t));
  32. if(!mf)
  33. return 0;
  34. mf->f = fopen(name,"w");
  35. if(!mf->f)
  36. {
  37. free(mf);
  38. return 0;
  39. }
  40.   fprintf(mf->f,"s = [n");
  41. return mf;
  42. }
  43. void matlab_close(matlab_file_t *mf)
  44. {
  45.   fprintf(mf->f,"];n");
  46. fclose(mf->f);
  47. free(mf);
  48. }
  49. void matlab_write(matlab_file_t *mf,float x[], int length)
  50. {
  51.   int i;
  52.   for(i=0;i< length;i++)
  53.     fprintf(mf->f,"%5f;n ",x[i]);
  54. }