vectors problem, como podria unir los vectores
    1 view (last 30 days)
  
       Show older comments
    
    ALEJANDRO ESPINOZA
 on 12 Aug 2020
  
    
    
    
    
    Commented: hosein Javan
      
 on 13 Aug 2020
            Como podria dar el valor del segundo vector al primero donde haya 0 ,ambos de  gran tamaño?
Pero que solo sustituya los valores de 0 hasta la longitud del vector A
por ejemplo:
A=[ 1 0 0 0 0 1 1 0 1 0 0 1 1 1 1 0 0 01 0 1 0 0];
B= [2 0 2 2 2 0 2 0 2 2 0 0 2 0 2 2 0 0 0 2 0 2 02 0 2 2 2 0 2 2];
Result=[ 1 2 2 2 2 1 1 2 1 2 2 1 1 1 1 2 2 1 2 1 2 2 ];
se que podria ser con un for, pero aun no logro interpretarlo ?
por favor podrian ayudarme 
0 Comments
Accepted Answer
  hosein Javan
      
 on 12 Aug 2020
        hola, es esto lo que esperas?
A = [1 0 0 0 0 1 1 0 1 0 0 1 1 1 1 0 0 0 1 0 1 0 0];
B = [2 0 2 2 2 0 2 0 2 2 0 0 2 0 2 2 0 0 0 2 0 2 0];
Result = A;
Result(A==0)=nonzeros(unique(B))
Result =
     1     2     2     2     2     1     1     2     1     2     2     1     1     1     1     2     2     2     1     2     1     2     2
8 Comments
More Answers (0)
See Also
Categories
				Find more on Resizing and Reshaping Matrices in Help Center and File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!