想把个数相同的cell合并了,例如,图中,1,2,3,4,6,7,8行那些都只有一个数,就想把它们合并起来,然后两个元素的也合并,例如行数是5,17,18的。
不知道该怎么写代码...

 Akzeptierte Antwort

0 Stimmen

给你个示例,看懂了就会了
cell = {{1},{2},{3},{4},{5,6}};
Out = {};
kk = 1
for ii = 1:length(cell)
if size(cell{ii})==1
Out(kk) = cell{ii};
kk = kk+1;
end
end

Weitere Antworten (0)

Kategorien

Mehr zu MATLAB 快速入门 finden Sie in Hilfe-Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!