vector problem , Suma de vectores
Show older comments
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 Comments
David Hill
on 12 Aug 2020
Your example does not make any sense to me. Please explain more clearly.
ALEJANDRO ESPINOZA
on 12 Aug 2020
Accepted Answer
More Answers (1)
David Hill
on 12 Aug 2020
R=A;
a=A==0;
b=B(B~=0);
R(a)=b(1:nnz(a));
1 Comment
ALEJANDRO ESPINOZA
on 12 Aug 2020
Categories
Find more on Introduction to Installation and Licensing in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!