Multiport switch with code
古いコメントを表示
Hello,
I am trying to create a multiport switch with code. I have a control vector and 40 other vectors stored as one matrix (called data). The control vector denotes which of the 40 data vectors to pass through. All 41 of these vectors (control and 40 data vectors columns) have the same number of elements. So ultimately, I would like to create one vector with chunks from each of the 40 data vectors (dependent on what the control vector specifies). Another user suggested doing this by indexing but I don't completely understand his code (found below). Any help would be greatly appreciated. I'm very new to indexing and could use any information provided.
Thanks in advance.
Btw, this is a sample control stream. My actual one is immense but I have limited it to 20000 elements so a method that does this faster than a for loop (if possible) would be great.
ControlStream = [0 1 1 3 2 3 3 1 4 1 5 5 6 4 7 9 8 2 9 1 10 1];
newStream = [];
startindex = ControlStream(1:2:end);
endindex = startindex+10;
streamNum = ControlStream(2:2:end);
for i = 1:length(startindex)
newStream = [newStream DataMatrix(startindex(i):endindex(i),streamNum(i))];
end
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Matrix Indexing についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!