hi every one, i need help to make something in matlab that i don't if it can be done or not , thank you
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
mina massoud
el 1 de Jul. de 2019
Respondida: Star Strider
el 1 de Jul. de 2019
A=[ 5 4 9 0 0 1 3 8 2 1 ]
B=[ 0 0 1 3 2 5 8 0 0 2 ]
C=[ 6 3 0 5 7 3 1 3 4 0 ]
if n=1:10
X=[ A ; B ; C] % in need this when all value are difference from zero so i need an output 3x10
X=[ A; B] % when value of C is zero i need output 2x10
X=[ A ;C] %% when value of B is zero i need output 2x10
X=[ B ;C] %% when value of A is zero i need output 2x10
so what i need in the code is when the value of the element of a vector is zero , i dont want to consider it inside the loop , always with the same variabile if it possibile
thank you
0 comentarios
Respuesta aceptada
Star Strider
el 1 de Jul. de 2019
Try this:
It uses:
X = X(~all(X == 0,2),:) % Deletes Zero Rows
to delete the rows that are all 0.
For example:
A=[ 5 4 9 0 0 1 3 8 2 1 ];
B=[ 0 0 1 3 2 5 8 0 0 2 ];
C=[ 6 3 0 5 7 3 1 3 4 0 ];
X = [A; zeros(size(A)); C]
X = X(~all(X == 0,2),:) % Deletes Zero Rows
producing:
X =
5 4 9 0 0 1 3 8 2 1
6 3 0 5 7 3 1 3 4 0
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Get Started with MATLAB en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!