空行列の判定方法

24 views (last 30 days)
kanako machii
kanako machii on 7 Jan 2021
Answered: Akira Agata on 8 Jan 2021
セル配列のある場所が空行列[]であったとき、それを判定してある数字を代入したいです。
具体的には、A{1,1}(1,:)が[]のとき、A{1,1}(1,:)=[0 0];
としたいです。
宜しくお願い致します。

Answers (1)

Akira Agata
Akira Agata on 8 Jan 2021
以下の方法ではどうでしょうか?
% 例として、A(1,2)とA(2,1)がカラのセル配列を作成
A = cell(2,2);
A{1,1} = rand(2);
A{2,2} = rand(2);
% カラのセルのインデックスを取得
idx = cellfun(@isempty,A);
% カラのセルに [0 0] を格納
A(idx) = {[0 0]};

Tags

Community Treasure Hunt

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

Start Hunting!