Constructing matrix elements conditionally (and sequentially)
이전 댓글 표시
Hi,
I have two matrices of differing lengths:
A = [1 1 0 1 0 0 1 0 1 0 1] B = [25.4 17.3 11.6 9.2 14.3 15.0]
I want to construct a matrix (C) that is the same length of A, but the 1 values are sequentially replaced by those in matrix B to yield:
C = [25.4 17.3 0 11.6 0 0 9.2 0 14.3 0 15.0]
Can anyone direct me to any relevant functions/methods that can do this?
As an aside, sum(A)==length(B) in all cases. However, sum(A) and length(B) will both vary with each iteration.
Thank you immensely.
Dave
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!