How can i merge arrays without certain value?

7 vues (au cours des 30 derniers jours)
Ayman Abdalla
Ayman Abdalla le 7 Jan 2021
Commenté : Ayman Abdalla le 7 Jan 2021
Let's say x=[0, 212], y=[22, 0, 0, 233] and z=[0, 0,33]
I want to combine (x, y, z) in one array(total) without 0 and in sequence Total=(22, 212, 33, 233)

Réponse acceptée

Sibi
Sibi le 7 Jan 2021
x=[0, 212]; y=[22, 0, 0, 233] ; z=[0, 0,33];
xn=length(x) ;yn=length(y);zn=length(z);
l=max([xn yn zn]);
o=[x zeros(1,l-xn)]+[y zeros(1,l-yn)]+[z zeros(1,l-zn)];
o(o==0)=[];
  1 commentaire
Ayman Abdalla
Ayman Abdalla le 7 Jan 2021
It's working Thank you for your time

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Multidimensional Arrays dans Help Center et File Exchange

Produits


Version

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by