please suggest me how to solve this problem

Unable to perform assignment because the size of the left side is 1-by-273 and the size of the right side is 1-by-273-by-2.

1 Comment

It would help to see the line of code, and to know the size() of all of the variables mentioned on the line.

Sign in to comment.

 Accepted Answer

The error is clear and simple. You are trying to save more number of elements then initialized into the matrix.
A = zeros(2,3) ; % initialize A as 2*3 matrix
% save elements
A(:,1) = rand(2,1) ; % no error
A(:,2) = rand(2,1) ; % no error
A(:,3) = rand(3,1) ; % error, as LHS is expecting array 2*1 but RHS is 3*1
Similiarly, in your case you have initialized matrix as size 1*273, but you are trying to save a matrix 1*273*2. You need to change your initialized LHS matrix accordingly.

More Answers (0)

Categories

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!