Convert 0×1 empty double column vector to zero

조회 수: 94 (최근 30일)
Zeynab Mousavikhamene
Zeynab Mousavikhamene 2019년 8월 30일
댓글: James Tursa 2019년 8월 31일
I am running a code and some of the parameters are 0×1 empty double column vector. Is there any way to convert these to zero?
I mean isntead of daying empty double, assign zero.
  댓글 수: 1
James Tursa
James Tursa 2019년 8월 30일
We need more details. Are you tring to change the behavior of a function or calculation that returns empty variables? Are you tring to change empty variables in the workspace to 0's? Are these empty variables part of a cell or struct array?

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

채택된 답변

James Tursa
James Tursa 2019년 8월 30일
Is this construct all you need?
if( isempty(x) )
x = 0;
end
  댓글 수: 5
Zeynab Mousavikhamene
Zeynab Mousavikhamene 2019년 8월 30일
@james I am doing some calculations for example a=b+c. it is in the loop and c is changing. Sometimes c is "0×1 empty double column vector" and sometimes it is a reall number. When it is empty, I get error in a=b+c. That's why I need to make sure that if c is empty, just replace it with zero. I want to avoid using if conditional.
James Tursa
James Tursa 2019년 8월 31일
What is the calculation you are doing that is producing the empty variable?

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by