Clear Filters
Clear Filters

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

4 views (last 30 days)
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 Comments
Joydeb Saha
Joydeb Saha on 6 Sep 2022
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.

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!