Assign value zero to n elements of cell array
古いコメントを表示
Hi all,
I am declaring a cell array to hold some numeric and non numeric data. I want to set the first row, all columns, equal to the numeric value zero. Something like this:
myCell = cell(5, 500);
myCell{1,:} = 0;
Which gives the error:
The right hand side of this assignment has too few values to satisfy the left hand side.
I've tried a number of other things, none worked, so have resorted to doing it in a loop. It works, but I really don't like it. Is there a simple way I'm missing?
Cheers, Karl
採用された回答
その他の回答 (2 件)
Parna Bhattacharya
2018 年 3 月 17 日
1 投票
Thanks;
1 件のコメント
Benjamin
2019 年 12 月 12 日
This also works:
A =
1 2 3
4 5 6
7 8 9
in order to zero the ith row: (i = 1)
A(1,:) = [0]
>> A =
0 0 0
4 5 6
7 8 9
Jeffery Devereux
2018 年 3 月 7 日
0 投票
Nice! Thanks (Had the same issue) Never thought about using the curly brackets around the zero.
カテゴリ
ヘルプ センター および File Exchange で Logical についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!