how to delete all the elements from the matrix?

4 ビュー (過去 30 日間)
Roma
Roma 2014 年 3 月 27 日
回答済み: Jos (10584) 2014 年 3 月 27 日
i want to delete all the elements from the matrix, and make the matrix empty.
  1 件のコメント
Walter Roberson
Walter Roberson 2014 年 3 月 27 日
What data type is the matrix? Should the empty matrix have the same data type?

サインインしてコメントする。

回答 (3 件)

Chandrasekhar
Chandrasekhar 2014 年 3 月 27 日
a = [1 2;3 4]
to make this matrix empty.then
a = [];

RAGHAVENDRA
RAGHAVENDRA 2014 年 3 月 27 日
編集済み: RAGHAVENDRA 2014 年 3 月 27 日
Are you trying to make the matrix as null matrix or want to replace the elements with zeros(erasing the values). In the former case just use A=[];

Jos (10584)
Jos (10584) 2014 年 3 月 27 日
Several options, depending on the desired result (same class, for instance):
A = []
A(:) = []
A = zeros(0,0,class(A))

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by