Filter löschen
Filter löschen

Add zero to make length divisible by 3

1 Ansicht (letzte 30 Tage)
hdiba
hdiba am 6 Aug. 2016
Kommentiert: hdiba am 6 Aug. 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!

Akzeptierte Antwort

Azzi Abdelmalek
Azzi Abdelmalek am 6 Aug. 2016
id=mod(-numel(A),3)
A(end+1:numel(A)+id)=0

Weitere Antworten (0)

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!

Translated by