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

2 次查看(过去 30 天)
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.

请先登录,再进行评论。

回答(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 CenterFile Exchange 中查找有关 Spectral Estimation 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by