help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: pass sting as function argument?


From: cube1982
Subject: Re: pass sting as function argument?
Date: Fri, 19 Sep 2008 14:48:05 -0700 (PDT)

That works great!! Thanks Ben! By the way, what does vars{:} do? Would you
point me to somewhere I can find information about this if you are not able
to spend time on this topic. Any keywords or terms I should search for?

Thanks again


Ben Abbott wrote:
> 
> On Friday, September 19, 2008, at 02:24AM, "cube1982"
> <address@hidden> 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
> 
> _______________________________________________
> Help-octave mailing list
> address@hidden
> https://www-old.cae.wisc.edu/mailman/listinfo/help-octave
> 
> 

-- 
View this message in context: 
http://www.nabble.com/pass-sting-as-function-argument--tp19566866p19579860.html
Sent from the Octave - General mailing list archive at Nabble.com.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]