vector problem , Suma de vectores
Ältere Kommentare anzeigen
Como podria dar el valor del segundo vector al primero donde haya 0 , ejemplo lo haga 1 por uno
(solo lo cambie los valores(2) del vector B , rellenen los ( 0 ) del vector A , pero solo hasta la longitud del vector A (length))
por ejemplo:
A=[ 1 0 0 0 0 1 1 0 1 0 0 1 1 1 1 0 0 0 1 0 ];
B=[ 2 0 .5 1.4 0 .88 0 .45 .49 0 0 .23 0 .39 .18 0 0 -0.15 0 -.12 0 -.22 0 1.7 -.25 .41 -.35 -.12 ];
R=[ 1 2 .5 1.4 .88 1 1 .45 1 .49 .23 1 1 1 1 .39 .18 -.15 1 -.22 ];
se que podria ser con un for, pero aun no logro interpretarlo ?
por favor podrian ayudarme
2 Kommentare
David Hill
am 12 Aug. 2020
Your example does not make any sense to me. Please explain more clearly.
ALEJANDRO ESPINOZA
am 12 Aug. 2020
Akzeptierte Antwort
Weitere Antworten (1)
David Hill
am 12 Aug. 2020
R=A;
a=A==0;
b=B(B~=0);
R(a)=b(1:nnz(a));
1 Kommentar
ALEJANDRO ESPINOZA
am 12 Aug. 2020
Kategorien
Mehr zu Introduction to Installation and Licensing finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!