Read and taking selected lat-longs from few .loc files and plot in geoshow

조회 수: 7 (최근 30일)
Joydeb Saha
Joydeb Saha 2022년 8월 30일
댓글: Joydeb Saha 2022년 9월 6일
I have 92 .loc files in the current folder. The volume of all the files is large. I need to read all the files one by one and select column 2 and 3 (lats and lons) in 30N to 90N latitudinal range. And place them in one .mat file. Therefore with that .mat file I can plot a geoshow map. How to do that?
  댓글 수: 5
Chunru
Chunru 2022년 8월 31일
For each fie, you can cut it down to few lines.
Joydeb Saha
Joydeb Saha 2022년 9월 6일
clear all
myFolder = 'U:\W\';
filePattern = fullfile(myFolder, '*.loc');
Files = dir(filePattern);
for k =1:length(Files)
% k=1
baseFileName = Files(k).name;
fullFileName = fullfile(myFolder, baseFileName);
fprintf(1, 'Now reading %s\n', fullFileName);
fid = fopen(fullFileName,'rt');
a = textscan(fid, '%s %s %f %f %f %f %f', ...
'Delimiter',',', 'CollectOutput',1);
M(:) = [a{2}];
M1=M(:,1:2);
lat_idx=find(M1(:,1)>=30 & M1(:,1)<=90);
WSC=M1(lat_idx,:);
end
I have done that much. I think it reads all the files, but giving the output for one file only. It should be somethink like : It will read first file, keep the first and second column and put the other file's first and second column in the same .mat file.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Import and Export에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by