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

5 次查看(过去 30 天)
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

采纳的回答

Sailesh Kalyanapu
Sailesh Kalyanapu 2022-10-10
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:

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Cell Arrays 的更多信息

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by