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.
이전 댓글 표시
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
SYARIFAH NUR DIYANA SYED LAMSAH
2021년 1월 27일
Siddharth Bhutiya
2021년 1월 29일
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.
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!