pass sting as function argument?

Ben Abbott bpabbott at mac.com
Fri Sep 19 15:41:09 CDT 2008


On Friday, September 19, 2008, at 02:24AM, "cube1982" <cube.1982 at yahoo.com> wrote:
>
>I'am trying to write a function to simply load a mat file and save its
>content in a text file. Here is my code:
>
>function mat2txt(matfilename, textfilename)
>tmpfile = load matfilename;
>save -text textfilename tmpfile;
>endfunction
>
>In the commandline, I typed the following line to call this function:
>> mat2txt('c:\octave\myfile\data1.mat', 'c:\octave\myfile\data1.txt');
>
>But this doesn't work. Anyone can help me with this? 
>

I'm not able to test this at the moment, but perhaps

function mat2txt(matfilename, textfilename)
tmpfile = load (matfilename);
vars = fieldnames (tmpfile);
load (matfilename);
save ('-text', textfilename, vars{:});
endfunction

Note that Matlab includes the qualifier "-struct" which would make this a bit simpler if included in Octave.

Ben



More information about the Help-octave mailing list