Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

I have a folder named 'means' which has further sobfolders numbered from '1979-2015', each subfolder has 12 files, i want to process each of that file. But how to call this folder , subfolder and further all the files.

1 vue (au cours des 30 derniers jours)
Sophia
Sophia le 16 Mar 2016
Clôturé : MATLAB Answer Bot le 20 Août 2021
% this is how i am going to process each of these files
fid1 = fopen(filename, 'r', 'ieee-le');
data = fread(fid1, 390963, 'int16');
tdata = reshape(data,3,361,361);
fclose(fid1);
u = squeeze(tdata(1,:,:)./10);
v = squeeze(tdata(2,:,:)./10);
error = tdata(3,:,:);
nu = u.*cos(rlong) + v.*sin(rlong);
nv = -u.*sin(rlong) + v.*cos(rlong);

Réponses (1)

Image Analyst
Image Analyst le 16 Mar 2016
You can use a function built for this. It's called genpath() and generates a list of all subfolders below the specified folder. Attached is an example where I go into all subfolders and then use dir() to get a list of files living in that folder.
  3 commentaires
Image Analyst
Image Analyst le 17 Mar 2016
I don't understand this. If I wanted to do something and someone showed me a way that I hadn't thought of, I would use it. If it was somewhat more clever or tricky than I would have thought up on my own, I might still use it as long as it make sense and I was able to understand/follow it. But whatever - do what you want. There are more complicated ways to get the sub-directories using just dir() instead of genpath() if you want to discover it or develop it on your own. Anyway, good luck.
Sophia
Sophia le 17 Mar 2016
I am already using the one that you have given me..But just trying to figure out the other ways of doing the same thing. I appreciate the fact that you are a very good programmer.

Cette question est clôturée.

Community Treasure Hunt

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

Start Hunting!

Translated by