MATLAB: Resizing an array – removing elements

arrayMATLAB

I have an array of data, in this case 61 rows long. I need to reshape this into 3s – LSB1 = reshape(LSB,3,[]); but as 61 isn't divisible by 3, it wont work.
I want to be able to remove the last value of from the vector in this case, via an if statement (sometimes maybe to remove the last 2 values if there were 62 rows instead) i.e. an if statement to check divisibility by 3 and then to remove the correct number of elements from the end of the array.
Thank you

Best Answer

If you only want 60 rows in your array, just redefine a new array to have 60 rows:
LSB = rand(61,1); % Create Data
LSBnew = LSB(1:60,:);
LSB1 = reshape(LSBnew, [], 3);