For Loop to Assign Values from Table to Variables

2 ビュー (過去 30 日間)
Nat Person
Nat Person 2021 年 3 月 30 日
回答済み: Walter Roberson 2021 年 3 月 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
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
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

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by