Want to save 10x33 cell in different files in loop
1 次查看(过去 30 天)
显示 更早的评论
I want to save the output that is a 10x33 cell array in for loop in 10 folders. Because 10 filters i used to filter 33 records. So i want to save these as text file for 10 filters differently in different folders. Also it will be good if different named folder is made using loop only
3 个评论
Rik
2022-3-14
Obviously the for keyword will not be enough to select a cell, generate a file name and call a function to store that selected cell in a file with that generated file name.
Did you check out those links I posted? One of the suggestions is to show what you have tried already. People are much more likely to help you then do all your work for you.
回答(1 个)
Ravi
2023-10-14
Hi Saurabh Sharma,
I understand that you are trying to store each row of the 10x33 cell array into a different file in different folders.
Kindly follow the below-mentioned approach to save the cell array in different files in text format.
For each row in the cell array.
- Create a generic name for the folder, say call it “datafolder”. Concatenate the row number to the generic folder name for saving the corresponding row file. You can create a folder using the “mkdir” function.
Example: generic folder name = “datafolder”
Folder name for second row of data = “datafolder2”.
- Extract the ith row of data using indexing operations on the cell array.
- Similarily, create a generic filename for output, say “datafile”. Now, concatenate the row number to the generic file name.
Example: generic file name = “datafile”
File name for second row of data = “datafile2.txt”
- Save the extracted row of data in a file using the “writecell” function.
Perform the above steps for all rows of data (in your case 10). You can use a for loop to iterate over the data.
Kindly go through the below mentioned links for a better understanding of the functions,
- mkdir:
https://in.mathworks.com/help/matlab/ref/mkdir.html
- writecell: https://in.mathworks.com/help/matlab/ref/writecell.html
Hope the above-mentioned procedure helps you resolve the issue you are facing.
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!