Extract variables from table and function with loop
显示 更早的评论
Hi,
I have a table with 2317X16, which contains 16 variables of 2317X1. Name of each variable is MC1, MC2, MC3, MC4 ....
I would like to do a msbackadj function of each variable by using loop, then plot it separately.
(Name of another variable for X axis of msbackadj is 'Mshift', also size of 2317X1)
So I use:
for i = 1:16
Mc3 = msbackadj(Mshift,M3a(:,'i'));
Figure;plot(Mshift, M3a(:,'i'));
end
(Mc3 is random name I made for new variable)
And it just worked for 1 variable, but didn't go the loop.
How can I do msbackadj on each variable with using loop?

Thanks,
1 个评论
Dyuman Joshi
2024-4-10
Using indexing (column numbers) instead of accessing by defining names manually would be a better option.
You can also get the variable names from the table and loop over them.
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Construct and Work with Object Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!