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

조회 수: 20 (최근 30일)
kanako machii
kanako machii 2020년 8월 8일
답변: Akira Agata 2020년 8월 10일
任意のセルが空だった場合に[0]を代入する方法を教えてください。
例えば
if A{1,1}(1,1)=[]
のとき
A{1,1}(1,1)=[0 0]
としたいです。
宜しくお願いします。

채택된 답변

Akira Agata
Akira Agata 2020년 8월 10일
例えば、以下のような処理はいかがでしょうか?
% 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개)

카테고리

Help CenterFile Exchange에서 データ型에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!