採用された回答

Mark
Mark 2014 年 1 月 15 日
編集済み: Mark 2014 年 1 月 15 日

6 投票

for i = 1:length(pathrisk)
if isempty(pathrisk(i))
pathrisk(i) = 0;
end
end

その他の回答 (1 件)

Jos (10584)
Jos (10584) 2014 年 1 月 15 日
編集済み: Jos (10584) 2014 年 1 月 15 日

28 投票

If I am not mistaken, the variable pathrisk is a cell array with some empty cells?
pathrisk = {1 [] 5 3 [] [] 9} % example data
tf = cellfun('isempty',pathrisk) % true for empty cells
pathrisk(tf) = {0} % replace by a cell with a zero

4 件のコメント

Abolfazl Nejatian
Abolfazl Nejatian 2019 年 11 月 27 日
Dear Jos,
your responce was very helpful for me.
thank you so much.
Fernando Galaz Prieto
Fernando Galaz Prieto 2020 年 9 月 23 日
Upvoting!
Thank you very much.
Abdullateef Agbaje
Abdullateef Agbaje 2021 年 1 月 23 日
Thank you
Ioannis Vourvachakis
Ioannis Vourvachakis 2021 年 10 月 11 日
thank you so much!!

サインインしてコメントする。

カテゴリ

ヘルプ センター および File Exchange で Operators and Elementary Operations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by