1
function matfile2sci(mat_file_path,result_file_path)
2
// Translate a Matlab 5 MAT file into a Scilab file
4
// mat_file_path : path of the Matlab MAT file
5
// result_file_path : path of the generated Scilab file
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
14
ReadmiMatrix=ReadmiMatrix; //load the matfile functions
17
fdi=open_matfile(mat_file_path)
18
fdo=mopen(result_file_path,'w')
20
//--read the file header
21
[head,version,endian]=matfile_header(fdi)
24
exec(LoadMatConstants,-1);
26
//--loop on the stored variables
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+')')
35
mclose(fdi);mclose(fdo)