How to find the maximum number of Consecutive dry days over time period?

6 Ansichten (letzte 30 Tage)
alagu mathi am 24 Mär. 2015
Kommentiert: Image Analyst am 25 Mär. 2015
Hi,
I have daily precipitation data in a netcdf format. I have to calculate Consecutive dry days for a June,July,August,September(JJAS) monsoon. I have an array it is having 122 values with single coloum. I have to find out what is the maximum number of consecuitive dry days and also which month?
Can any one help me to clear this?
Thank you.
0 Kommentare-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

Antworten (2)

David Sanchez am 25 Mär. 2015
I way of doing what you need with no need of toolboxes or special functions is this. Obviously, it would be much easier if you use some built-in matlab functions, but it works this way too:
monsoon_array = randi([0 1],122,1); % 122x1 array with 0s and 1s randomly distributed. I did this to have data to work with
max_dry = 0; % initialize the maximum number of consecuitive dry days
counter = 0;
for k=1:122
if monsoon_array(k) == 0
counter = counter + 1;
else
if counter > max_dry
max_dry = counter;
max_dry_position = k - counter;
end
counter = 0;
end
end
-> max_dry will return the maximum number of consecuitive dry days
-> max_dry_position will return the initial position (day) of the consecutive dry days
2 KommentareKeine anzeigenKeine ausblenden
alagu mathi am 25 Mär. 2015
Bearbeitet: alagu mathi am 25 Mär. 2015
What I mean whenever the data(rain fall) is < 1mm that day is considered as dry day. Can you suggest me where can i give that condition ?
I attached the text file which i have.
Thank you
Image Analyst am 25 Mär. 2015
dry = data < 1;
Better information will yield better answers from us.

Melden Sie sich an, um zu kommentieren.

Image Analyst am 24 Mär. 2015
Exactly what do you have, and what do you need? Do you have an N row by 2 column array where column1 is the date and column2 is the precipitation? Do you already have a way to get your data in from the cdf file? What does "calculate consequitive dry days" mean? Do you want an array of the number of days in each dry spell? Do you want the dates of those days also? Can you supply a cdf file with code to read it in? Or can you supply an numerical example? Can you read this and fix your question? Right now there are too many things for us to guess on so we'd have to put in too much work to cover all possibilities, or else make some assumptions and end up not doing what you need. Also, do you have the Image Processing Toolbox because the regionprops() function in there would make this really easy?
0 Kommentare-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Text Data Preparation finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by