~ubuntu-branches/ubuntu/hoary/scilab/hoary

« back to all changes in this revision

Viewing changes to macros/util/matfile2sci.sci

  • Committer: Bazaar Package Importer
  • Author(s): Torsten Werner
  • Date: 2005-01-09 22:58:21 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20050109225821-473xr8vhgugxxx5j
Tags: 3.0-12
changed configure.in to build scilab's own malloc.o, closes: #255869

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
function matfile2sci(mat_file_path,result_file_path)
 
2
// Translate a Matlab 5 MAT file into a Scilab file
 
3
// 
 
4
// mat_file_path : path of the Matlab MAT file
 
5
// result_file_path : path of the generated Scilab file  
 
6
//
 
7
//This function has been developped following the "MAT-File Format" description:
 
8
//www.mathworks.com/access/helpdesk/help/pdf_doc/matlab/matfile_format.pdf 
 
9
 
 
10
//Copyright INRIA
 
11
//Author Serge Steer  
 
12
  
 
13
 
 
14
  ReadmiMatrix=ReadmiMatrix; //load the matfile functions 
 
15
 
 
16
  //--file opening
 
17
  fdi=open_matfile(mat_file_path)
 
18
  fdo=mopen(result_file_path,'w') 
 
19
  
 
20
  //--read the file header
 
21
  [head,version,endian]=matfile_header(fdi)
 
22
  
 
23
  //--set constants
 
24
  exec(LoadMatConstants,-1);
 
25
 
 
26
  //--loop on the stored variables
 
27
  while %t 
 
28
    //[Matrix,Name]=ReadmiMatrix(fdi) //read next variable
 
29
    ierr=execstr('[Matrix,Name]=ReadmiMatrix(fdi)','errcatch') //read next variable
 
30
    if ierr<>0 then mclose(fdi),mclose(fdo),return,end 
 
31
    if meof(fdi) then  break,end //EOF reached 
 
32
    execstr(Name +'= Matrix; save(fdo,'+Name+')')
 
33
  end
 
34
  //--file closing
 
35
  mclose(fdi);mclose(fdo)
 
36
endfunction
 
37