Using regexp on a double array
古いコメントを表示
I'm trying to extract variable names and years from my file names, but getting an error from regexp.
Example of code:
%Call up files
pwd
fuf(pwd, 'detail');
fn=fuf(['/Users/katharynwoods/Documents/MATLAB/Research/MATLAB/flux_sensitivity_analysis/Met_drivers/sens_heat/*shtfl.nc*'],'detail');
load(char(fn{1}));
%Extract variable names
pieces = regexp(fn, '\/', 'split');
p=pieces{1};
driver = p{9};
but I get this error message:
Undefined function 'regexp' for input arguments of type 'double'.
Is there a different function I should be using on double arrays? Thanks!
9 件のコメント
Tom
2013 年 6 月 24 日
fn appears to be a cell based on the load line, what does it consist of?
Walter Roberson
2013 年 6 月 25 日
If "fn" is a cell so that fn{1} is a string that is the name of a file, then the only way that fn can be double two lines later is if the load() is clobbering "fn".
It is not completely impossible that fn{1} is a numeric value or vector that char() can be applied to in order to get a file name, but it seems unlikely.
Tom
2013 年 6 月 25 日
When you load fn{1}, are any of the variables that you load also called fn?
Kate
2013 年 6 月 25 日
Walter Roberson
2013 年 6 月 25 日
Then load() must be replacing "fn".
Put a breakpoint in before the load. Examine class(fn) . "step" past the load. Examine class(fn). Has it changed? What does
which regexp
return?
Kate
2013 年 6 月 25 日
per isakson
2013 年 6 月 25 日
編集済み: per isakson
2013 年 6 月 25 日
Matlab (R2012a) does not have a function, load, which reads NetCDF-files.
Doc says: ncdisp, Display contents of NetCDF data source in Command Window
Try
ncdisp( '[...]alysis/Met_drivers/sens_heat/shtfl.1902.nc') % use full name
and read the documentation on NetCDF
回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Data Import and Analysis についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!