How do I replace [ ] in an array with 0's
古いコメントを表示

How can i replace the [] in the pathrisk field with 0's?
Thanks for your help!
採用された回答
その他の回答 (1 件)
Jos (10584)
2014 年 1 月 15 日
編集済み: Jos (10584)
2014 年 1 月 15 日
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
2019 年 11 月 27 日
Dear Jos,
your responce was very helpful for me.
thank you so much.
Fernando Galaz Prieto
2020 年 9 月 23 日
Upvoting!
Thank you very much.
Abdullateef Agbaje
2021 年 1 月 23 日
Thank you
Ioannis Vourvachakis
2021 年 10 月 11 日
thank you so much!!
カテゴリ
ヘルプ センター および File Exchange で Characters and Strings についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!