Unable to save individual cells of 2D cell array with save() function

6 Ansichten (letzte 30 Tage)
Hi,
I have a 2D cell array that consits of 1x5 cells and each one of them is a separate 1x122 cell array.
When I am trying to save each of the 5 cells in a different file with save() function, I get the following error:
Error using save
'trace_set{1}' is not a valid variable name.
My code looks like this:
save(fname3,'trace_set{1}','-v7.3');
save(fname4,'trace_set{2}','-v7.3');
save(fname5,'trace_set{3}','-v7.3');
save(fname6,'trace_set{4}','-v7.3');
save(fname7,'trace_set{5}','-v7.3');
Is there an option to save individual cells of a 2D cell array, beside saving the complete cell array as is?
Thanks,
Nassos

Akzeptierte Antwort

Sailesh Kalyanapu
Sailesh Kalyanapu am 10 Okt. 2022
As per my understanding, you are looking to save individual cell elements using save() function.
save()’ function can be used to save individual cell elements as well as the entire cell.
But when using ‘save()’ function, names of the variables to be saved, are to be specified as character vectors or string scalars.
Thus to save individual elements of cell array, you would have to assign the individual element to a new scalar variable name
Example code:
Temp_variable = trace_set{1};
save(fname3,'Temp_variable','-v7.3');
For more information related to 'save()' function, refer to the documentation:

Weitere Antworten (0)

Kategorien

Mehr zu Cell Arrays finden Sie in Help Center und File Exchange

Produkte


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by