Error : Subscripted assignment dimension mismatch.
1 次查看(过去 30 天)
显示 更早的评论
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
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 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Discrete Data Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!