How to remake matrix by using specific cell data??
조회 수: 8 (최근 30일)
이전 댓글 표시
I have a 1X4 cell and 4X12 matrix
cell(1,1) = [3,4,5,7,9]
cell(1,2)= [3,4,5,6,7,8,9,10,11,12]
cell(1,3) = [1,4,6,7,8,9,11,12]
cell(1,4) = [4,5,8,9,10,11,12]
Matrix = [1 2 3 4 5 6 7 8 9 10 11 12;
4 5 6 7 8 9 10 11 12 1 2 3;
7 8 9 10 11 12 1 2 3 4 5 6;
12 10 11 9 8 7 6 5 4 3 2 1];
I want to make another matrix by using cell data like...
New_Matrix = [0 0 3 4 5 0 7 0 9 0 0 0;
0 0 6 7 8 9 10 11 12 1 2 3;
7 0 0 10 0 12 1 2 3 0 5 6;
0 0 0 0 8 7 0 0 4 3 2 1];
I tried many time but error like subindex is not defined for cell and dimension is not matched... pleases help me.
댓글 수: 1
Jan
2016년 11월 4일
편집: Jan
2016년 11월 4일
Please explain the magic relation between the inputs and the outputs. We could guess the wanted procedure, but it is more efficient, if you reveal this important detail. If you post your code, suggesting an improvement would be much easier.
Please post your inputs such, that we can copy&paste it in Matlab directly. Otherwise trying to create a solution requires more typing for all voluntary helpers. Thanks.
답변 (1개)
Jan
2016년 11월 4일
Perhaps - a bold guess:
C = {[3,4,5,7,9], ...
[3,4,5,6,7,8,9,10,11,12], ...
[1,4,6,7,8,9,11,12], ...
[4,5,8,9,10,11,12]};
M = [1 2 3 4 5 6 7 8 9 10 11 12; ...
4 5 6 7 8 9 10 11 12 1 2 3; ...
7 8 9 10 11 12 1 2 3 4 5 6; ...
12 10 11 9 8 7 6 5 4 3 2 1];
NewM = zeros(size(M));
for k = 1:size(M, 1)
NewM(k, C{k}) = M(k, C{k});
end
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!