Urgent: I dont have a clue how to merge to Matrices and split-up Arrays.
Mostrar comentarios más antiguos
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 comentarios
Saad Siddiqui
el 4 de Mzo. de 2012
Walter Roberson
el 4 de Mzo. de 2012
http://www.mathworks.com/matlabcentral/answers/29922-why-your-question-is-not-urgent-or-an-emergency
Respuestas (1)
Honglei Chen
el 4 de Mzo. de 2012
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?
Categorías
Más información sobre Logical en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!