フィルターのクリア

how can I make the matrix empty when it has the values.

1 回表示 (過去 30 日間)
Z D
Z D 2017 年 9 月 18 日
回答済み: Walter Roberson 2017 年 9 月 18 日
this is my code.
if j~= p(t,1)
D{j}(i,[1,2,3,4])=Cl(i,[1,2,3,4]);
else
Cl(i,[1,2,3,4])% here is my problem I want C1 to be empty but I do not know how to write?!
end

回答 (1 件)

Walter Roberson
Walter Roberson 2017 年 9 月 18 日
You can delete values, and you can overwrite an entire matrix with an empty matrix, but you cannot overwrite part of a matrix with emptiness, unless the matrix is a cell array.
Cl(i,:) = [];
would delete all of row #i from C1.
c1(i,1) = [];
would delete just the element in column 1 of row #i. But as a side effect, because holes are not allowed in numeric arrays, the entire array would become a single column vector, the same as if you had done:
t = c1(:); %make it a column vector
t( sub2ind(size(c1), i, 1) ) = []; %delete the one element of the column vector
c1 = t; %that is the new c1
After that, there would be no c1(i,2) because it would be down to a single column.

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by