Error : Subscripted assignment dimension mismatch.

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 个评论

We do not have any information as to how R1 relates to the actual size of M_ROCK
The R1 is the row index of M_ROCK
No it is not, not in the posted code.
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 个)

类别

帮助中心File Exchange 中查找有关 Discrete Data Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by