MATLAB: How to clear the error on the code

reshape

if true
x_of_size_of_U=W;
y_of_size_of_U=L;
U=[ho,E2];
for i=1:n
reshaped_U=reshape(U,x_of_size_of_U,y_of_size_of_U);
end
end
the error is given below
Error using reshape To RESHAPE the number of elements must not change.
Error in fincode (line 227) reshaped_U=reshape(U,x_of_size_of_U,y_of_size_of_U);

Best Answer

Change the line
reshaped_U=reshape(U,x_of_size_of_U,y_of_size_of_U);
to
reshaped_U=reshape(U,x_of_size_of_U,[]);
or
reshaped_U=reshape(U,[],y_of_size_of_U);
Related Question