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
댓글 수: 0
채택된 답변
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 Center 및 File Exchange에서 Cell Arrays에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!