필터 지우기
필터 지우기

Saving some part of a cell array

조회 수: 13 (최근 30일)
Yongmin
Yongmin 2015년 2월 22일
댓글: Yongmin 2015년 3월 2일
Hello,
I have a 1x11 cell and want to save some columns of the cell (from 1st column to 8th column only) into a MAT-file.
data =
columns 1 through 4
[21350235x8 char] [21350235x6 char] [21350235x6 char] [21350235x1 int32]
columns 5 through 8
[21350235x64 char] [21350235x10 char] [21350235x1 int32] [21350235x1 int32]
columns 9 through 11
{21350235x1 cell} {21350235x1 cell} {21350235x1 cell}
Columns 9 ~ 11 consist of character strings of variable lengths containing unicode texts. If I try to save them in MAT-file, MATLAB requires to use -v7.3 switch. The saved MAT file has too large size, I want eliminate columns 9 through 11 instead.
Could you please tell me how to do it?
Many thanks!
  댓글 수: 8
Titus Edelhofer
Titus Edelhofer 2015년 2월 24일
There was a typo in Geoff's comment, it should be
data = data(1:8);
instead.
Titus
Yongmin
Yongmin 2015년 2월 24일
Thanks Geoff and Titus. I tried to accessing each element of the cell by data{1}, data{2}, and so on. Anyhow your comment were very helpful.

댓글을 달려면 로그인하십시오.

채택된 답변

Titus Edelhofer
Titus Edelhofer 2015년 2월 24일
Hi,
you should be able to index into data without destroying data or doing copies:
dataTruncated = data(1:8);
save someFile.mat dataTruncated
If you prefer to have the data in the file called "data", then cut of the last cells as Geoff suggested and then save ...
Titus
  댓글 수: 10
Titus Edelhofer
Titus Edelhofer 2015년 2월 25일
Hi,
what I would do is to write two small helper functions "myload" and "mysave", that e.g. saves individual entries of your cell array to individual .mat files (maybe zip them together if you prefer to have one file), and for load to the opposite of reading the individual files.
Titus
Yongmin
Yongmin 2015년 3월 2일
Thanks a lot for your idea, Titus. I will follow your suggestion.
Regards, Yongmin

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Cell Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by