Error : Subscripted assignment dimension mismatch.
1 view (last 30 days)
Show older comments
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!
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/637945/image.png)
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 Comments
Walter Roberson
on 2 Jun 2021
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.
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!