For loop to carry value down depending on another matrix value
이전 댓글 표시
Hello!
I have the following issue. I have 2 matrices (MatrixA and MatrixB), I want to create a third one(MatrixC) that uses the information on both as follows:
MatrixA MatrixB MatrixC
_______ _______ ______
0 150 0
0 1100 0
0 50 0
-1 20 0 When MatrixA switches from 0 to -1 use MatrixB Value,
-1 120 20 and copy that value all the way down until MatrixA
-1 70 20 turn to 1 and then repeat for every other instance
-1 90 20 very likely a for loop way.
1 100 20
0 101 0
-1 115 0
-1 110 115
-1 160 115
-1 200 115
-1 275 115
-1 400 115
-1 500 115
1 504 115
Preferably MatrixC maintains same size as MatixA OR MatrixC that’s why the zeros filling the gaps when it’s not applicable. Thanks so much for the help!
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!