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 commentaire

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

Connectez-vous pour commenter.

 Réponse acceptée

KSSV
KSSV le 12 Mai 2021
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.

Plus de réponses (0)

Catégories

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by