how do i lopping many data in one folder ?

I have data per hour in a folder with two different data types. I want to use the data to get one result, but the existing script can only run per hour. I want to run it directly in 1 month.I attach the data script.
can anyone guide me to lopping the data directly within 1 month?
thanks

2 个评论

What do you mean by lopping? Lopping means to cut off to make shorter, like cropping. Is that what you mean - to crop your data? Or do you mean looping, like in a "for" or "while" loop? The FAQ shows you that: http://matlab.wikia.com/wiki/FAQ#How_can_I_process_a_sequence_of_files.3F
Sorry, I mean looping, like in for or while loop

回答(1 个)

Did you read the link provided by Image Analyst already? http://matlab.wikia.com/wiki/FAQ#How_can_I_process_a_sequence_of_files.3F.
Use sprintf to define the file names. I cannot guess, which pattern is used to create them:
InFile = 'HMW816010100CAL.dat'
nama_file = 'HMW816010100IR1'
OutFile = 'Gondanglegi_01jan_00.txt'
Perhaps:
for k = 1:31
InFile = sprintf('HMW81601%02d00CAL.dat', k)
nama_file = sprintf('HMW81601%02d00IR1', k);
OutFile = sprintf('Gondanglegi_%02djan_00.txt', k)
...
end
The months and years can be adjusted by sprintf also. Maybe a dir helps to get a klist of existing files at first.

5 个评论

I can ruuning that file,but the data it's not change, which only one data. How to fix it? Thank you
Suvany Aprilia's "Answer" moved here:
Thank for the answer
@Suvany Aprilia: Which file can you "run", and what does this exactly mean? Which data are not changed? Please post the relevant part of you modified code and explain exactly, what you want to be fixed.
Look in the command window. It will report the file name of "InFile". What do you see? Does it change as k changes? It should.
@jan I will explain, I have two of type data, .dat and .pgm for every hour of the month (more than 100file in one folder). so, the results I expect later, the hourly results for each day of the month, after I "run" data "lopping" as I expected. however, the results obtained are the same as using only one time data. hopefully can be understood

此问题已关闭。

标签

关闭:

2021-8-20

Community Treasure Hunt

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

Start Hunting!

Translated by