Dynamically specifying table columns in a loop - with a row number...
11 次查看(过去 30 天)
显示 更早的评论
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).
0 个评论
采纳的回答
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 个评论
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.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1407039/image.png)
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 Exchange 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!