[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Input files to function script
From: |
David Grundberg |
Subject: |
Re: Input files to function script |
Date: |
Mon, 28 Feb 2011 00:44:57 +0100 |
User-agent: |
Thunderbird 2.0.0.24 (X11/20101027) |
SalveH skrev:
> I have a function script kalled named sppl.m that I run from octave command
> line with many wav-files as input.
>
> %%%%%
> function sppl (varargin)
> for i = 1:length (varargin)
> file = varargin{i};
> ...
>
> %%%%%
>
> The function works well used like this:
> octave:> sppl "file1.wav" "file2.wav" "file3.wav"
> but I'd like to be able to do something similar to the shell:
> bash> script file*wav
> to avoid all that typing!
>
> I've been told that by using functions such as 'dir' or 'ls' or 'glob' etc.
> this should be possible. Somehow ..
>
> (I've tried something like this:
> octave:> files = dir ("*wav")
> octave:> sppl (files)
> I understand why THAT don't work. Probably each file has to be referred to
> as files(n).name. But I can't get that to work either..)
>
> I now give up and need HELP!
>
>
Hi Salve,
sppl (glob ("*.wav"){:});
or
sppl (dir ("*.wav").name);
should do the trick. Notice that dir ().name is a cs-list and glob ()
returns cell array that I convert to a cs-list by using the {:} syntax.
hth,
Grundberg