ERROR: Subscripting a table using linear indexing (one subscript) or multidimensional indexing (three or more subscripts) is not supported. Use a row subscript and a variable subscript.
Show older comments
Hello experts. I am doing a coding for two tables to find the common factor for a new table. Undamaged table have 269 datas whereas damaged table have 317 datas. I want MATLAB to find the same X Location (column 2) and extract to new table. Below are the coding. However i got error, kindly help to resolve my problem.
% load tables (damaged & undamaged)
x_undamaged = undamaged(:,2);
x_damaged = damaged(:,2);
deforamtion_damaged = damaged(:,5);
deforamtion_undamaged = undamaged(:,5);
%To compare x nodes and extract corresponding deformation for the node
i=1
j=1
for i=1:317
if x_damaged(i) == x_undamaged(i)
new(j,1)= x_damaged(i);
new(j,2)= deformation_damaged(i);
new(j,3) = deformation_undamaged(i);
i=i+1;
j=j+1
else
i=i+1
end
end
2 Comments
SYARIFAH NUR DIYANA SYED LAMSAH
on 27 Jan 2021
Siddharth Bhutiya
on 29 Jan 2021
When you do x_damaged = damaged(:,2) it will generate a table with 1 variable. Hence when you try to index into x_damaged later on as x_damaged(i), you get the error, since you need 2 indices to subscript into a table. It looks like you just want to extract that vector. So you can use brace indexing for that
x_damaged = damaged{:,2}
After this the code should work fine.
Answers (0)
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!