why the repeated number is lost?
2 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
采纳的回答
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.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Mathematics and Optimization 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!