How to create a number of output tables at each iteration ?

1 次查看(过去 30 天)
Dear altruists,
Seek suggestion.
I have a "TW" table where TW(:,1) = start row number and TW(:,2) = end row number is mentioned.
I have a "D" table where raw data is present. D is a table which has 1 to 15,000 rows and 10 cols. For each iteration, I have to pick values from "D" table ( copy) with specified rows & cols. and drop it to an output table (paste them) and the requirement is that the output data table name will be change from Z1.........Z20.
I want to output various table for every iteration.
For example,
i =1 will create output table Z1 = D(rows, cols)
i = 2 will create output table Z2 = D(rows, cols)
.
.
i =20 will create output table Z20 = D(rows, cols)
**************************************************************************
for i = 1 : 20
cols = [1 2 5 7];
rows = TW(i,1):(TW(i,2));
Z = D(rows,cols);
end
  5 个评论
MD Rabiul Islam
MD Rabiul Islam 2022-6-20
I also find this comment during googling...Can I request any alternative easiest solution to do this ?
Stephen23
Stephen23 2022-6-20
"Can I request any alternative easiest solution to do this ?"
Indexing.

请先登录,再进行评论。

回答(1 个)

Abhishek Chakram
Abhishek Chakram 2023-10-3
Hi MD Rabiul Islam.
It is my understanding that you are facing difficulty to extract multiple rows and columns from a bigger table and store it in multiple named variables. As a workaround, you can create a cell array to achieve a similar result. Here is an example for the same:
Z={};
for i = 1 : 20
cols = [1 2 5 7];
rows = TW(i,1):(TW(i,2));
Z{i} = D(rows,cols);
end
In this example, "Z" is a cell array. You can access each sub table using indexing as shown below:
Z{1}
Z{2}
You can refer to the following documentation to know more about the functions used:
Best Regards,
Abhishek Chakram

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

标签

产品


版本

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by