Info

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

Subscripted assignment dimension mismatch.

1 Ansicht (letzte 30 Tage)
yasser
yasser am 24 Mär. 2020
Geschlossen: MATLAB Answer Bot am 20 Aug. 2021
Hello, I traied to put the results (2 string rows) into Final_Solutions workspace
Final_Solutions =zeros();
for i=1 : Mat_A_Rows
Final_Rows = size(Final_Solutions,1);
for j=1 : 1
if (Mat_A_bests(i,j) ~= 0 && Mat_A_bests(i,j+1) ~= 0 && Mat_A_bests(i,j+2) ~= 0 )
Final_Solutions(Final_Rows+1,:) = cell2mat([Mat_A_STRS_RAW(i,1) Mat_A_STRS_RAW(i,j+1) Mat_A_STRS_RAW(i,j+2) Mat_A_STRS_RAW(i,j+3)]);
end
end
end
  2 Kommentare
Ameer Hamza
Ameer Hamza am 25 Mär. 2020
The error is probably caused by difference in dimensions of Final_Solutions(Final_Rows+1,:) and cell2mat([Mat_A_STRS_RAW(i,1) Mat_A_STRS_RAW(i,j+1) Mat_A_STRS_RAW(i,j+2) Mat_A_STRS_RAW(i,j+3)]). Add a breakpoint at this line and see why the number of elements are not equal.
Adam
Adam am 25 Mär. 2020
Final_Solutions =zeros();
This should be pre-sized properly. All this does is declare a scalar 0, which is obviously not the correct size for your results in the for loop. Start off by pre-sizing it to the size your result should be.

Antworten (0)

Diese Frage ist geschlossen.

Community Treasure Hunt

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

Start Hunting!

Translated by