任意の空セルに数値を代入する方法を教えてください

任意のセルが空だった場合に[0]を代入する方法を教えてください。
例えば
if A{1,1}(1,1)=[]
のとき
A{1,1}(1,1)=[0 0]
としたいです。
宜しくお願いします。

 採用された回答

Akira Agata
Akira Agata 2020 年 8 月 10 日

0 投票

例えば、以下のような処理はいかがでしょうか?
% Sample cell array (A(1,2) and A(2,2) are empty)
A = {'abc',[];123,''};
% Detect empty cell(s) and fill with 0(s)
idx = cellfun(@isempty,A);
A(idx) = {0};

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchangecell 配列 についてさらに検索

質問済み:

2020 年 8 月 8 日

回答済み:

2020 年 8 月 10 日

Community Treasure Hunt

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

Start Hunting!