pass sting as function argument?

Ben Abbott bpabbott at mac.com
Fri Sep 19 17:59:03 CDT 2008


On Sep 19, 2008, at 5:48 PM, cube1982 wrote:

>> function mat2txt(matfilename, textfilename)
>> tmpfile = load (matfilename);
>> vars = fieldnames (tmpfile);
>> load (matfilename);
>> save ('-text', textfilename, vars{:});
>> endfunction
>
> 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

"vars" is a cell array of strings.

(vars{:}) is equivalent to (vars{1}, vars{2}, vars{3},  
vars{4}, ... ,vars{end})

It is a very nice feature/trick!

Ben


More information about the Help-octave mailing list