空行列の判定方法
이전 댓글 표시
セル配列のある場所が空行列[]であったとき、それを判定してある数字を代入したいです。
具体的には、A{1,1}(1,:)が[]のとき、A{1,1}(1,:)=[0 0];
としたいです。
宜しくお願い致します。
답변 (1개)
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]};
카테고리
도움말 센터 및 File 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!