Difficulty to get the results by using repmat function
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Nataraja M
el 11 de Jun. de 2019
Comentada: Jan
el 14 de Jun. de 2019
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.
load BCC_CF_Mul_pr_1961.mat
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
0 comentarios
Respuesta aceptada
Jan
el 11 de Jun. de 2019
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, :);
6 comentarios
Jan
el 14 de Jun. de 2019
@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.
Más respuestas (0)
Ver también
Categorías
Más información sobre Climate Science and Analysis en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!