Unable to save individual cells of 2D cell array with save() function
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
nassos
el 6 de Oct. de 2022
Comentada: nassos
el 12 de Oct. de 2022
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
0 comentarios
Respuesta aceptada
Sailesh Kalyanapu
el 10 de Oct. de 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:
Más respuestas (0)
Ver también
Categorías
Más información sobre Cell Arrays en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!