matlab - Store user input as wildcard -
i having trouble data processing function in matlab. function takes name of file processed input, finds desired files, , reads in data.
however, several of desired files variants, such data_00.dat, data.dat, or data_1_march.dat. within function, search files containing data , condense them 1 usable file processing.
to solve this, desiredfile converted wildcard.
here statement use.
selectedfiles = dir *desiredfile*.dat % search file names containing desiredfile
this returns files containing variable name desiredfile, rather user input.
the solution can think of writing separate function manually condenses variants 1 file before function run, trying keep number of files used down , avoid this.
you concatenate strings that. considering desiredfile
variable.
desiredfile = input('files: '); selectedfiles = dir(['*' desiredfile '*.dat']) % search file names containing desiredfile
enclosing strings between square brackets [string1 string2 ... stringn]
concatenates them. matlab's dir function receives string.
Comments
Post a Comment