How do I replace [ ] in an array with 0's
Mostra commenti meno recenti

How can i replace the [] in the pathrisk field with 0's?
Thanks for your help!
Risposta accettata
Più risposte (1)
Jos (10584)
il 15 Gen 2014
Modificato: Jos (10584)
il 15 Gen 2014
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 Commenti
Abolfazl Nejatian
il 27 Nov 2019
Dear Jos,
your responce was very helpful for me.
thank you so much.
Fernando Galaz Prieto
il 23 Set 2020
Upvoting!
Thank you very much.
Abdullateef Agbaje
il 23 Gen 2021
Thank you
Ioannis Vourvachakis
il 11 Ott 2021
thank you so much!!
Categorie
Scopri di più su Characters and Strings in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!