Why is my variable undefined?

 采纳的回答

Walter Roberson
Walter Roberson 2018-4-27

1 个投票

You only define g if age >= 8.
Perhaps you want an "end" after you assign a=0 after your age test.

更多回答(1 个)

Not all options for your if-structure will result in defining g
if age<1
a=.4;
else
if (age>=1) && (age<3)
a=.6;
elseif (age>=3) && (age<5)
a=.7;
elseif (age>=5) && (age<10)
a=.5;
else
%only here g will be defined

类别

帮助中心File Exchange 中查找有关 Testing Frameworks 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by