I am new in MATLAB programming and unable to solve the following problem
I have a matrix A
of size example: 1*16 such as
A = [.01 0 0 0 .42 0 0 0 .13 0 0 0 .09 0 0 .32]
and another matrix B
of size 16*16 with all values of column the same
B = [.12 .18 .08 .17 .43 .13 .13 .24 .09 .11 .04 .08 .10 .15 .08 .43]
each row same as first row.
I want to replace columns of B
with columns of A
but if 0
is present in A
I should keep the value of B
of that column the same.
I want to get output as 16*16 matrix with a sample row matrix C
as:
C = [.01 .18 .08 .17 .42 .13 .13 .24 .13 .11 .04 .08 .09 .15 .08 .32]
I would be pleased to get support.