Clear a Matrix from a multidimensional Matrix at each iteration

1 回表示 (過去 30 日間)
AMEHRI WALID
AMEHRI WALID 2019 年 11 月 20 日
コメント済み: AMEHRI WALID 2019 年 11 月 20 日
Hello Everyone,
I want at each iteration, to clear the matrix corresponding to this iteration from a multidimensional Matrix.
So here is my code.
A(:, :, 1, 1) = rand(5, 5);
A(:, :, 1, 2) = rand(5, 5);
A(:, :, 1, 3) = rand(5, 5);
whos
for i = 1:3
A(:, :, 1, i) = [];
whos
end
I don't understand why this doesn't work, normally A(:, :, 1, i) is a matrix so the command is correct, but it is telling me that a null assignement can have only one non-colon index.
Can anyone help me please to solve this problem ?
Thans in advance

採用された回答

JESUS DAVID ARIZA ROYETH
JESUS DAVID ARIZA ROYETH 2019 年 11 月 20 日
Matlab needs to make sure that all the indexes include all the values included, therefore it needs to be ":", I leave the solution:
A(:, :, 1, 1) = rand(5, 5);
A(:, :, 1, 2) = rand(5, 5);
A(:, :, 1, 3) = rand(5, 5);
whos;
for i=3:-1:1
A(:, :, :, i) = [];
whos
end

その他の回答 (0 件)

カテゴリ

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