change cell dimension
古いコメントを表示
hi all y teachers,
i have a cell :
a = {{8x1cell} {14x1cell} {11x1cell} {23x1cell} {17x1cell} {8x1cell} {18x1cell} {14x1cell} {20x1cell} {28x1cell}}
i need to change the dimension of each cell to a fix number, say 50x1 cell. So each cell will have dimension 50x1, and i want the rest rows of the cell to be 0 or []
ex: take the 1st col of the cell, it's 8x1cell and i need it to be 50x1 with 42rows left to be zero or []
old 8x1cell = {'i'; 'need'; 'a'; 'glass'; 'of'; 'water'; 'right'; 'now'}
new 8x1cell = {{'i'; 'need'; 'a'; 'glass'; 'of'; 'water'; 'right'; 'now'; 0; 0; ... till row 50}
is there any possible way i can perform that? really need your helps, plzz! :(
thx,
Maya
採用された回答
その他の回答 (2 件)
Jan
2011 年 10 月 13 日
for k=1:length(a)
L = length(a{k});
a{k}(L+1:50) = {0};
end
1 件のコメント
Javier
2020 年 11 月 17 日
Hello there, lets say I have the cell array
1×6 cell array
{8791×1 double} {8782×1 double} {8802×1 double} {8795×1 double} {8806×1 double} {8791×1 double}
I need to change all of them to be
{8782×1 double}
So that I would have a 1×6 cell array where there is repeated {8782×1 double}
Rusmaya Luthfina
2011 年 10 月 14 日
0 投票
5 件のコメント
Fangjun Jiang
2011 年 10 月 14 日
The answer is yes. Treat it no differently than any other variable. Put it in the output argument.
Also, see update in my answer. It provided both ways to pad with zero or with [].
Rusmaya Luthfina
2011 年 10 月 17 日
Rusmaya Luthfina
2011 年 10 月 17 日
Rusmaya Luthfina
2011 年 10 月 17 日
Alexander Sidelev
2018 年 4 月 3 日
What is the solution to your problem? I can't figure it out
カテゴリ
ヘルプ センター および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!