Filter löschen
Filter löschen

Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

Subscripted assignment dimension mismatch. (Matrices)

1 Ansicht (letzte 30 Tage)
mike
mike am 11 Feb. 2017
Geschlossen: MATLAB Answer Bot am 20 Aug. 2021
I'm trying to define three matrices -- a(i), b(i), and c(i) -- for the values of 1,2, and 3. (see code)
for i = 1:3,
a(i) = [(Sy - S(i)) Tyz; Tyz (Sz - S(i))];
b(i) = -[Txy Tyz; Txz (Sz - S(i))];
c(i) = [Txy (Sy - S(i)); Txz Tyz];
end
I keep getting the same error message, "Subscripted assignment dimension mismatch." How can I fix this?

Antworten (1)

Geoff Hayes
Geoff Hayes am 11 Feb. 2017
mike - the error message is telling you that you are making an invalid assignment. For example, the following produces the same error
a = zeros(5,1);
a(:,1) = [1:4]';
because we are trying to assign a column of four elements to a column that is expecting five elements.
Which line of code is generating your error? How have you initialized a, b, and c? Try using the debugger to step through your code and make sure that the assignments that you are attempting make sense given the initialization of the variables.

Community Treasure Hunt

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

Start Hunting!

Translated by