## Difficulty to get the results by using repmat function

### Nataraja M (view profile)

on 11 Jun 2019
Latest activity Commented on by Jan

on 14 Jun 2019

### Jan (view profile)

Hello everyone, I am working on climate data and I have a matrix size of 12x361, (where the 12 represents the months and 361 represents the columns).
Now i want to repeat the factor values of each corresponding months (Jan-Dec) of the 361 stations into 30years (say 1931 to 1961) on the daily wise.
For example i have "Jan" month factor value of 0.778, "Feb" month is 0.65, "Mar" is 0.56 ....and Dec is 0.69, Now i want to repeat the each factor value
of the particular months into days and into 30years for all the 361 stations and the data should be arranged serially (say Jan-1931, Feb-1931... Dec-1960)
I have tried the code below shown for your reference and required your valuable suggestions to proceed further.
b=BCC_CF_Mul_pr_1961(:,1:361); %12rows of factor values for all the 361 stations
% Inserts Year and Months
x=bsxfun(@(Month,Year) datenum(Year,Month,1),(1:12).',1931:1960);
x=x(:);
d=datevec(x);
d=d(:,1:2);
%inserting number of days in a month of the year
a1=eomday(d(:,1),d(:,2));
%Repeat the evry month of the factor values to the days caculated from the previous step
a2=repmat(b(1),a1(1),1); %this line repeats the values only for that month
Kindly help me to proceed further
Thank you

### Jan (view profile)

2019 年 6 月 11 日
採用された回答

I'm not sure, what you are asking for. With some guessing:
a1 = eomday(d(:,1),d(:,2));
index = repelem((1:size(b, 1)).', a1);
a2 = b1(index, :);

Jan

### Jan (view profile)

2019 年 6 月 13 日
Of course you can ask any Matlab related questions in this forum. Simply open a new thread.
Here in Europe it is unusual to call other persons "sir". So please do not bother, if other users or me do not use this epxression. It is not meant impolite.
Nataraja M

### Nataraja M (view profile)

2019 年 6 月 14 日
Thank you, below code was refered to carry out timeseries trend to detect the increase or decrease in the precipitation. The size of the data was arranged by annualy for 361 climate stations, Acordingly i have arranged my data annualy (arranged in rows) and tried to calculate the trend and i got the results for the particular station (or single station arranged in column wise), but the problem is i have 361 climate station data for the 116 annual years, how to use this code to get the value "tau" for all the 361station. Previously i used XLStat trail version to calculate the "tau" value, in that i have selected all the 361 station data and got the results for all the individula station how to do the same in the matlab using the below code
I have made some modfication in the code written by the author to calculate the tau and also attached the data for your reference.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Simone Fatichi -- simonef@dicea.unifi.it
% \$Date: 2009/10/03 \$
A=Annual_IMD_Pr_1901_2016(:,4); % select the required station data
V=reshape(A,length(A),1);
alpha = 0.05/2;
n=length(V);
i=0; j=0; S=0;
for i=1:n-1
for j= i+1:n
S= S + sign(V(j)-V(i));
end
end
VarS=(n*(n-1)*(2*n+5))/18;
StdS=sqrt(VarS);
%%%% Note: ties are not considered
if S >= 0
Z=((S-1)/StdS)*(S~=0);
else
Z=(S+1)/StdS;
end
p_value=(1-normcdf(abs(Z))); %% one-tailed test
pz=norminv(1-alpha);
H=abs(Z)>pz;
D=n*(n-1)/2;
tau=S/D; %Trend value for the particular station
return
Jan

### Jan (view profile)

2019 年 6 月 14 日
@Nataraja M: As far as I can see, this is a new question. Then, as said already, open a new thread to ask it. This is better than attaching a new question as a comment in another thread.
"how to do the same in the matlab using the below code" - this is hard to answer, because I do not really understand what you have done with which other software. Please post, what the inputs are and what you need as output.