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

4 次查看(过去 30 天)
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 个评论
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 中查找有关 Low-Level File I/O 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by