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 个评论
回答(1 个)
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 Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!