空行列の判定方法

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

답변 (1개)

Akira Agata
Akira Agata 2021년 1월 8일
以下の方法ではどうでしょうか?
% 例として、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]};

카테고리

Help CenterFile Exchange에서 Statistics and Machine Learning Toolbox에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!