Want to save 10x33 cell in different files in loop

1 Ansicht (letzte 30 Tage)
saurabh sharma
saurabh sharma am 9 Mär. 2022
Beantwortet: Ravi am 14 Okt. 2023
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 Kommentare
saurabh sharma
saurabh sharma am 14 Mär. 2022
How to save it ..I am not able to save each cell array in different named folders using loop only. As you can see it is 10x33 cell and in each cell there are 2048 values.
Rik
Rik am 14 Mär. 2022
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.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Ravi
Ravi am 14 Okt. 2023
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.
  1. 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”.
  1. Extract the ith row of data using indexing operations on the cell array.
  2. 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
  1. 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.

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by