필터 지우기
필터 지우기

Error : Subscripted assignment dimension mismatch.

조회 수: 2 (최근 30일)
Chao Zhang
Chao Zhang 2021년 5월 31일
댓글: Walter Roberson 2021년 6월 2일
When I ran the following code to the line 'M_ORE(i,:) = table2array(M_ROCK(i,:));', the error 'subscripted assignment dimension mismatch' appeared.
This is the screenshot of part dataset, I want to transfer values from M_ROCK into M_ORE1 and M_ORE2 according to the 'r1_mill_tonnage' and 'r2_mill_tonnage' strings.
Therefore, how to slove the error 'sunscripted assignment dimension mismatch' and get the correct objective matrix?
Many thanks in advance for your help!
elseif rock_index == 2
%%
M_ROCK = rock;
M_ROCK = array2table(M_ROCK,'VariableNames',G_Value.Properties.VariableNames);
%
num=input('Please enter the number of rock types:');
%
M_WASTE = zeros(R1,C1);
M_ORE = zeros(R1,C1,num);
STR = cell(1,num);
for i = 1 : R1
for j = 1 : num
STR{j} = sprintf('r%d_mill_tonnage',j);
if table2array(M_ROCK(i,STR{j})) > 0
M_ORE(i,:) = table2array(M_ROCK(i,:));
else
M_WASTE(i,:) = table2array(M_ROCK(i,:));
end
end
end
  댓글 수: 4
Walter Roberson
Walter Roberson 2021년 6월 1일
No it is not, not in the posted code.
Walter Roberson
Walter Roberson 2021년 6월 2일
I would claim that R1 is not a current row index into M_ROCK, and is instead exactly 814723 .
You could disprove this claim by posting the code that sets R1 and by showing the size() of M_ROCK and the value of R1 at the time that the error occurs.

댓글을 달려면 로그인하십시오.

답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by