As described in the documentation, reshape() the 2nd and 3rd inputs should be integers and when those two integers are multiplied, it should equal the number of elements in the first input. That makes sense since the 2nd and 3rd inputs define the dimensions of a matrix.
In the case of your example, length(dataIn)/k equals 21.333 so you're asking for a matrix with 21.3 rows which doesn't make sense.
For your script to work, n must be a multiple of k and k must be an integer.
But there are additional areas of concern. For example, log2() is used to define k and that may not return an interger. Secondly, in the line that calls stem(), you hard-coded 1:128 so if you use n=126, you'll get an indexing error at that line. Likewise, in the second call to stem(), you've hard-coded 1:50 which would cause another index error.
Instead of hard coding these indices, you 1:numel(...) or 1:length(...).
