Superimpose matrices of different sizes
Mostrar comentarios más antiguos
Hello,
I have matrix A 2x5 of NaN
A=...
[NaN NaN NaN NaN NaN;
NaN NaN NaN NaN NaN]
and another B matrix 2x3:
B=...
[NaN 6 2;
NaN 1 0]
If the elements of B are postive (so not 0 nor NaN) I want to paste those elements into A, call this result matrix C
C=...
[NaN 6 2 NaN NaN;
NaN 1 NaN NaN NaN]
Thanks
Respuesta aceptada
Más respuestas (1)
This works only if A and B have the same number of rows:
ind = find(B>0);
C = A;
C(ind) = B(ind);
Categorías
Más información sobre Logical en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!