MATLAB: Add zero to make length divisible by 3

divisblemodreshapevectorzeros

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!

Best Answer

id=mod(-numel(A),3)
A(end+1:numel(A)+id)=0