For Loop to Assign Values from Table to Variables
조회 수: 2 (최근 30일)
이전 댓글 표시
I have a 6x16 table in my workspace. Each row of the table corresponds to a different aircraft type (for a total of 6 different aircrafts). How would I write a for loop that will cycle through each row of the table and assign the data in the row's columns to variables?
댓글 수: 1
David Hill
2021년 3월 30일
Why not just index the table when you want to use the data. It is very bad practice to assign different variables to data.
답변 (1개)
Walter Roberson
2021년 3월 30일
for rowidx = 1 : size(TheTable,1)
first_var = TheTable{rowidx, 1};
second_var = TheTable{rowidx, 2};
do something with first_var and second_var
end
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!