could anyone help me to solve the issue.

1 visualizzazione (ultimi 30 giorni)
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]
could anyone please help me on this.

Risposta accettata

Torsten
Torsten il 6 Ago 2019
idx = B==0;
B(idx) = A(idx)
  3 Commenti
Torsten
Torsten il 6 Ago 2019
A = ...;
w = ...;
w = logical(w);
B = ...;
A(w) = B(w);

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Multidimensional Arrays in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by