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

22 Ansichten (letzte 30 Tage)
kanako machii
kanako machii am 8 Aug. 2020
Beantwortet: Akira Agata am 10 Aug. 2020
任意のセルが空だった場合に[0]を代入する方法を教えてください。
例えば
if A{1,1}(1,1)=[]
のとき
A{1,1}(1,1)=[0 0]
としたいです。
宜しくお願いします。

Akzeptierte Antwort

Akira Agata
Akira Agata am 10 Aug. 2020
例えば、以下のような処理はいかがでしょうか?
% 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};

Weitere Antworten (0)

Kategorien

Mehr zu データ型 finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!