Hello everyone,
I created graph G It has 4 nodes (1,2,3,4), and 3 edges.
I created values G.Nodes.Zp, and I have created values G.Nodes.Z
G.Nodes.Zp values are [0,0,1,1]
I have control array which is
kontrola=[1;2;NaN;NaN]
I created a loop as follows
for i=1:1:length(kontrola)
if kontrola(i)==NaN
G.Nodes.Z(i)=G.Nodes.Zp(i);
end
end
But it doesn't work, no error, no anything.
By my logic G.Nodes.Z(3)&G.Nodes.Z(4) should get values from G.Nodes.Zp(3)&G.Nodes.Zp(4).
Thank you for your time,
Denis

 採用された回答

per isakson
per isakson 2016 年 6 月 18 日
編集済み: per isakson 2016 年 6 月 18 日

0 投票

Test
>> nan==nan
ans =
0
Replace
kontrola(i)==NaN
by
isnan(kontrola(i))
and run your code.
...
Because two NaNs are not equal to each other, logical operations involving
NaNs always return false, except ~= (not equal). Consequently,
NaN ~= NaN
ans =
1
NaN == NaN
ans =
0

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

質問済み:

2016 年 6 月 17 日

編集済み:

2016 年 6 月 18 日

Community Treasure Hunt

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

Start Hunting!

Translated by