フィルターのクリア

Re-Initialze existing cell with zeros without specifying dimensions

2 ビュー (過去 30 日間)
Jay
Jay 2016 年 10 月 5 日
コメント済み: Jay 2016 年 10 月 5 日
Is there a way to re-initialize an existing cell / array without specifying the dimensions of said cell / array?
Ie.
tempArr1(7,5) = zeros % First instance of use
tempArr1 = some function or command % Second instance of use returning the tempArr1 (7,5) of zeros?

採用された回答

Guillaume
Guillaume 2016 年 10 月 5 日
To set all the values of array x to 0:
x(:) = 0;

その他の回答 (2 件)

Massimo Zanetti
Massimo Zanetti 2016 年 10 月 5 日
Implicitly invoke the creation of a cell/array using the size of the object you want:
A=cell(4,5,6);
B=cell(size(A))
A=zeros(3,4,5);
B=zeros(size(A))
Is that what you need?

Walter Roberson
Walter Roberson 2016 年 10 月 5 日
tempArray(:) = 0;
Or
tempArray = zeros(sizeof(tempArray), class(tempArray) ) ;
Or
tempArray = 0 * tempArray ;
For cells...
tempArray = cellfun(@(C) 0*C,tempArray, 'uniform', 0)

カテゴリ

Help Center および File ExchangeShifting and Sorting Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by