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!