Urgent: I dont have a clue how to merge to Matrices and split-up Arrays.
古いコメントを表示
a) Given 2 data Matrices
Data A=[1 120 DataB= 1 90 1 130 2 92 2 140 3 93 3 180 3 160]
I need to merge the two Data sets so that the result looks like TargetData= 1 120 91 1 130 91 2 140 92 3 180 92 3 160 93
b) Array=[2,8,3,30,4,50,100,200,4,80,500]. It is required to split it up into three arrays with different ranges: [0-10],[10-100] and [100-1000]
HOW TO DO THIS??
2 件のコメント
Saad Siddiqui
2012 年 3 月 4 日
Walter Roberson
2012 年 3 月 4 日
http://www.mathworks.com/matlabcentral/answers/29922-why-your-question-is-not-urgent-or-an-emergency
回答 (1 件)
Honglei Chen
2012 年 3 月 4 日
For part (a), you can do the following:
DataA= [1 120
1 130
2 140
3 180
3 160];
DataB= [1 91
2 92
3 93];
cidx = bsxfun(@eq,DataA(:,1),DataB(:,1)');
for m = 1:size(cidx,2)
DataA(cidx(:,m),3) = DataB(m,2);
end
I didn't quite get part (b), could you elaborate more, just as you have done in part (a), what is the desired output?
カテゴリ
ヘルプ センター および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!