How do I add certain numbers from one cell to another?
조회 수: 1 (최근 30일)
이전 댓글 표시
CA = {[5 -10 2],[6 6 8],[0 9 -10 8 -10 3]};
CB = {[4 17 2],[6 6 10],[9 3 4 9 7 6]};
CC = {[1 2 4],[4 2 1],[1 7 3 1 2 2]};
for i = 1:length(CA)
idx = CA{i}==-10 ;
CB{i}(idx) = CB{i}(idx)+15 ;
end
The output I want is the "new" CB generated in the for loop. But now instead of adding 15 to all of them, I want to add different numbers to each depending on "CC."
For example:
Just looking at the first group of each cell:
CA = {[5 -10 2]}
CB = {[4 17 2]}
CC = {[1 2 4]}
I would like to add the difference between the "1 and 4" in CC (l1-4l=3), to the "17" in CB.
So the first group in the "new" CB will be {[4 20 2]}.
BTW. I chose the numbers "1 and 4" in CC because they are the numbers that would be adjacent to the -10 in CA.
댓글 수: 0
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!