How can i replace the [] in the pathrisk field with 0's?
Thanks for your help!

 채택된 답변

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.
Upvoting!
Thank you very much.
Thank you
thank you so much!!

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Characters and Strings에 대해 자세히 알아보기

질문:

2014년 1월 15일

댓글:

2021년 10월 11일

Community Treasure Hunt

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

Start Hunting!

Translated by