representation of a cell array in 2025b

조회 수: 36 (최근 30일)
Sebastian
Sebastian 2025년 10월 14일 9:48
편집: Stephen23 2025년 10월 14일 14:59
representation change of a cell array from 2024b to 2025b
for example I have all subfolder names from a folder in a cell array,
in 2024b i see the names of my folders but in 2025b I see this:
6×1 cell array
{1×1 cell}
{1×1 cell}
{1×1 cell}
{1×1 cell}
{1×1 cell}
{1×1 cell}
so the names are not visible any more in the cell array if it is an 1x1 cell.
are there some setting that could be changed that I see the content of the cells?
  댓글 수: 2
Dyuman Joshi
Dyuman Joshi 2025년 10월 14일 13:07
How did you obtain these subfolder names? Did you use any code for doing so?
Stephen23
Stephen23 2025년 10월 14일 14:35
편집: Stephen23 2025년 10월 14일 14:59
Dyuman Joshi asked the right question. More particularly, why are you nesting superfluous scalar cell arrays inside another cell array?
writematrix(pi,'somename.csv')
writematrix(23,'nextname.csv')
S = dir();
C = {S.name} % no superfluous nesting
C = 1×4 cell array
{'.'} {'..'} {'nextname.csv'} {'somename.csv'}
The data design would be the obvious thing to fix:
D = cellfun(@(n){n}, C, 'uni',0) % superfluous nesting
D = 1×4 cell array
{1×1 cell} {1×1 cell} {1×1 cell} {1×1 cell}

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

답변 (2개)

Star Strider
Star Strider 2025년 10월 14일 10:02
One option is to use the '{:}' representation to see the contents --
Names = {{'abc'},{'def'},{'ghi'},{'jklmnop'}}
Names = 1×4 cell array
{1×1 cell} {1×1 cell} {1×1 cell} {1×1 cell}
Names{:}
ans = 1×1 cell array
{'abc'}
ans = 1×1 cell array
{'def'}
ans = 1×1 cell array
{'ghi'}
ans = 1×1 cell array
{'jklmnop'}
.

Steven Lord
Steven Lord 2025년 10월 14일 14:26
If you have cells or structs inside of cells (as I suspect is the case in the original poster's question) you could use the celldisp function to recursively display the contents.
Names = {{'abc'},{'def'},{struct('abc', 'def'), 'ghi'},{'jklmnop', {1:5}}}
Names = 1×4 cell array
{1×1 cell} {1×1 cell} {1×2 cell} {1×2 cell}
celldisp(Names)
Names{1}{1} = abc Names{2}{1} = def Names{3}{1} = abc: 'def' Names{3}{2} = ghi Names{4}{1} = jklmnop Names{4}{2}{1} = 1 2 3 4 5

카테고리

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

제품


릴리스

R2025b

Community Treasure Hunt

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

Start Hunting!

Translated by