why the repeated number is lost?

조회 수: 2 (최근 30일)
bing xu
bing xu 2017년 12월 6일
댓글: bing xu 2017년 12월 11일
I want to synchronize 95 time series data, the code is:
combination=combnk(1:95,2) *
for k=1:length(combination)* %% k equals 1:4465 %%
m=combination(k,1) %%% Here is the problem. since k=1:4465, I would suppose m has 4465 elements but it turns out just has 94 elements. I would like to know how can I make 'm' display all elements in combination(k,1) but not lost those repeated ones%%%
n=combination(k,2)
tsa=vts(1,m)
tsb=vts(1,n)
[tsa(m),tsb(n)]=synchronize(tsa,tsb,'union');
end
%%vts is a timeseries collection which contain all the 95 time series data%%
From my code I would suppose 'm equals every element in combination first column, which should be 4465 elements. but indeed, m equals 1:94 that is 94 elements. it auto ignore repeat number like 1 is repeated 95 times in combination. I do not how to make it. Please I would like to hear all your comments. Thank you.

채택된 답변

Elizabeth Reese
Elizabeth Reese 2017년 12월 8일
The k is what is looping up to 4465. The m value will take on all of the values in the first column of combination which is 1 through 94. Most of these numbers do repeat, so m will have the same value for multiple iterations of the loop while n changes. It is the pair of m and n that is the unique combination. You can look at combination in the Variable Window to confirm this.
If you are not seeing the output that you expect, I would step through the script using the debugger and check that tsa and tsb are assigned correctly and updated properly. Without having vts, I cannot check that.
  댓글 수: 1
bing xu
bing xu 2017년 12월 11일
Thank you. I will do the debugger.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Mathematics and Optimization에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!