Azzera filtri
Azzera filtri

Want to save 10x33 cell in different files in loop

1 visualizzazione (ultimi 30 giorni)
saurabh sharma
saurabh sharma il 9 Mar 2022
Risposto: Ravi il 14 Ott 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 Commenti
saurabh sharma
saurabh sharma il 14 Mar 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 il 14 Mar 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.

Accedi per commentare.

Risposte (1)

Ravi
Ravi il 14 Ott 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.

Community Treasure Hunt

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

Start Hunting!

Translated by