vectors problem, como podria unir los vectores
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
ALEJANDRO ESPINOZA
am 12 Aug. 2020
Kommentiert: hosein Javan
am 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 Kommentare
Akzeptierte Antwort
hosein Javan
am 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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Resizing and Reshaping Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
