Convert 0×1 empty double column vector to zero

90 ビュー (過去 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 Center および File ExchangeInteractive Control and Callbacks についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by