Difficulty to get the results by using repmat function
조회 수: 1 (최근 30일)
이전 댓글 표시
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
채택된 답변
Jan
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, :);
댓글 수: 6
Jan
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.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Climate Science and Analysis에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!