Azzera filtri
Azzera filtri

Add zero to make length divisible by 3

1 visualizzazione (ultimi 30 giorni)
hdiba
hdiba il 6 Ago 2016
Commentato: hdiba il 6 Ago 2016
Hallo,
i have vector that i want to reshape into a matrix. Therefor i firstly need to prove if the length is divisible by 3. if not i want to add as much zeros at the end of the vector until the length is divisible by 3? can someone help? thanks!

Risposta accettata

Azzi Abdelmalek
Azzi Abdelmalek il 6 Ago 2016
id=mod(-numel(A),3)
A(end+1:numel(A)+id)=0

Più risposte (0)

Categorie

Scopri di più su Resizing and Reshaping Matrices in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by