How to fill in a matrix and compute its binary frequency?

2 ビュー (過去 30 日間)
Hydro
Hydro 2014 年 11 月 25 日
編集済み: dpb 2014 年 11 月 26 日
Hello All,
I have thirty year of preciptation data in a vector form. I need to find the frequency of the dry and wet days and plot the frequency against days (1:365).
I am stuck as the following code place in the precipitation data however, i am not able to change it to a binary condition (Wet=1, dry=0). Can somebody help me out. I still have to count all the wet and dry days and make the frequency graph against the days (1:365).
Thanks
R=zeros(365,30); % Space for the data
P_data=P(:,4); % Preciptation data
n=length(P_data);
C=1;
for i=1:30;
for j=1:365;
R(j,i)=P_data(C);
C=C+1;
end
end
if R(j,i)>0;
R(j,i)=1; % imposing the wet conditon if the the value in the ith row and jth colum is larger then zero
else
R(j,i)=0;
end
  3 件のコメント
Image Analyst
Image Analyst 2014 年 11 月 25 日
Yes, but you still didn't attach P, or give code to read it in.
Hydro
Hydro 2014 年 11 月 25 日
the data

サインインしてコメントする。

回答 (1 件)

dpb
dpb 2014 年 11 月 25 日
編集済み: dpb 2014 年 11 月 26 日
Leap years not accounted for?
If not, as the above would indicate, then
R=reshape(P_Data,365,[])>0;
  2 件のコメント
Hydro
Hydro 2014 年 11 月 25 日
yes, the leap year is ignored for this analysis. any thought about the code would be appreciated. I still don't see what i wanted to see (Probability of precipitation occurrence against duration in days (1:365).
dpb
dpb 2014 年 11 月 25 日
Not quite sure what you mean, precisely by Probability of precipitation occurrence against duration in days (1:365) but R above will be a logical array of T for rainy days arranged by year in columns. So, P(R|day) =
Prainbyday=sum(R,2)/size(R,2);
Clearly P(noRain) is the complement. Is that not what you're looking for?

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeDates and Time についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by