# could anyone help me to solve the issue.

1 view (last 30 days)
jaah navi on 6 Aug 2019
Commented: jaah navi on 6 Aug 2019
I am having two matrices
A =[0.2616 0.2642 0.2658 0.2658 0.2641 0.2606;
0.2131 0.1954 0.1776 0.1596 0.1408 0.1209;
0.1023 0.1066 0.1114 0.1162 0.1202 0.1233;
0.5003 0.4596 0.4150 0.3665 0.3148 0.2612]
B =[ 0 2.2721 2.0537 0 0 1.2945;
2.4707 1.3124 1.3201 0 1.5619 0;
1.2997 0 0 1.8159 1.3116 0;
0 0 0 1.3203 0 1.2975]
I want to get a matrix in such a way that all places of 0 in B should be get filled by the values present in A matrix .
The output of the matrix should be
[0.2616 2.2721 2.0537 0.2658 0.2641 0.2606;
2.4707 1.3124 1.3201 0.1596 1.5619 0.1209;
1.2997 0.1066 0.1114 1.8159 1.3116 0.1233;
0.5003 0.4596 0.4150 1.3203 0.3148 1.2975]

Torsten on 6 Aug 2019
idx = B==0;
B(idx) = A(idx)

jaah navi on 6 Aug 2019
Could you help me to solve the issue in the command
A(w)=B(w)
with respect to the matrices given below.
A=[ 3.5849 0.8097 0 0 3.2102 0;
0 0 3.4263 3.3205 0 0.7748;
0.8060 3.5170 0 0 0.7909 0;
0 0 0.8086 0.8024 0 3.1069]
w = [0 0 1 1 0 1;
1 1 0 0 1 0;
0 0 1 1 0 1;
1 1 0 0 1 0]
B =[1.6787 1.6868 1.6845 1.6708 1.6460 1.6111;
0.1607 0.1771 0.1980 0.2219 0.2471 0.2720;
8.6233 8.4297 8.1731 7.8765 7.5706 7.2873;
0.5791 0.4073 0.2409 0.0936 0.1000 0.2262]
When i run the command i am getting the following error
Subscript indices must either be real positive integers or logicals.
Error in line
A(w)=B(w)
Torsten on 6 Aug 2019
A = ...;
w = ...;
w = logical(w);
B = ...;
A(w) = B(w);
jaah navi on 6 Aug 2019
ok.It works.