why am i getting this error-" Error using dir Characters adjacent to a ** wildcard must be file separators"
조회 수: 37 (최근 30일)
이전 댓글 표시
>> %%%%% CODE TO EXTRACT TRMM DATA GRID WISE TO GENERATE TIME SERIES OF RAINFALL DEPTH AT 3 HR INTERVAL %%%%% BINDHU V M %TO LOAD ALL THE FILES dirpath=('D:\trmm2\todel\'); files=dir('D:\trmm2\todel\3B**'); nfiles=length(files);
datadir = 'D:\trmm2\todel\'; fname = '3B42.20071105.12.7A.SUB.nc'; lat1 = ncread([datadir,fname],'latitude'); lon1 = ncread([datadir,fname],'longitude'); %%%% TO EXTRACT THE DATA FOR INDIVIDUAL GRIDS mydata=[]; for i=1:nfiles filename=[dirpath files(i).name]; disp(['Processing ',files(i).name]); rain=ncread(filename,'pcp'); dd=flipud(rain'); c1=reshape(dd',13664,1); mydata=[mydata c1]; end data1=mydata'; % data1=data*3; %%%% TO GENERATE TEXT FILES WITH TIME SERIES OF rainfall intensitiy GRIDWISE for ii=1:13664 textfilename=['precip' num2str(ii) '.txt']; fid1=fopen(textfilename,'wt'); fclose(fid1); end for iii=1:13664 c=data1(:,iii); precip=c(:,:); textfilename=['precip' num2str(iii) '.txt']; fid1=fopen(textfilename, 'at+'); fprintf(fid1, [repmat('%d\t', 1, size(precip,2)) '\n'],precip'); fclose(fid1); end Error using dir Characters adjacent to a wildcard must be file separators.
댓글 수: 0
채택된 답변
Steven Lord
2018년 6월 20일
Because that's what the documentation says. Looking at the description in the "Input Arguments" section:
For example, dir */*.txt lists all files with a txt extension exactly one folder
under the current folder, and dir **/*.txt lists all files with a txt extension
zero or more folders under the current folder.
If you're looking for all the files whose names start with 3B in the directory D:\trmm2\todel\ use dir('D:\trmm2\todel\3B*').
If you're looking for all files in D:\trmm2\todel\ and its subdirectories whose names start with 3B, you want dir('D:\trmm2\todel\**\3B*').
If you're looking for something else, describe in more detail what files you want to locate using that dir call and we may be able to help you determine how to find those files.
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 File Operations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!