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 件)

Community Treasure Hunt

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

Start Hunting!

Translated by