MATLAB: Unable to perform assignment because the left and right sides have a different number of elements.

forloop

Best Answer

In your expression, the left hand side is just a scalar (only has one element) but you are trying to assign a length 4 column vector to it. This doesn't make sense.
It would be much simpler just to make your "100 sets of 4 random #'s" using one line in MATLAB
D = normrnd(50,10,[4,100])
This will produce a 4 by 100 matrix, where each column is a set of 4 random numbers