Dynamically specifying table columns in a loop - with a row number...

6 ビュー (過去 30 日間)
Corymbiamaculata
Corymbiamaculata 2023 年 6 月 9 日
編集済み: Stephen23 2023 年 6 月 9 日
I'm running a loop where I copy values from one table into another, dynamically specifying variable names (columns). I got this part covered by using:
myTable.(specifyColumnName) = ...
where specifyColumnName changes with each iteration depending on where I want to copy the values.
The problem is, I also need to specify the row number (also dynamically), and I can't figure out how to do it.
Any tips?
(I'm using a loop, because I can't get unstack to work the way I want, see my other question https://se.mathworks.com/matlabcentral/answers/1980044-restructuring-a-matrix-based-on-an-index?s_tid=prof_contriblnk).

採用された回答

Stephen23
Stephen23 2023 年 6 月 9 日
編集済み: Stephen23 2023 年 6 月 9 日
"Any tips?"
Read the MATLAB documentation:
From you description, it seems that you might want to use curly braces:
myTable{rowNumber,columnName} = ...
  2 件のコメント
Corymbiamaculata
Corymbiamaculata 2023 年 6 月 9 日
Thanks, it's not so straightforward to find answers in the documentation when you're a beginner and don't know what you're looking for.
Stephen23
Stephen23 2023 年 6 月 9 日
編集済み: Stephen23 2023 年 6 月 9 日
"it's not so straightforward to find answers in the documentation..."
The MATLAB documentation makes it very easy to find related information.
For example, you are using tables. Here is the TABLE documentation:
Also: scroll to the bottom of every page: there you will find lists of related functions, links to related documentation pages, and more.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by