Array size does not equal scalar value?

New to MATLAB. Having an error with provided, source code that states:
if (size(h,1) ~= Nx+1)
error('size(h,1) must be equal to Nx+1');
end
So I set:
h=rand(101,1);
Nx=100;
But for some reason I still get this error even though I try to verify that the two are equal by:
size(h,1)==Nx+1
ans =
logical
1
Thanks for helping a newbie to MATLAB.

回答 (1 件)

the cyclist
the cyclist 2019 年 9 月 22 日

0 投票

When I run this code:
h=rand(101,1);
Nx=100;
if (size(h,1) ~= Nx+1)
error('size(h,1) must be equal to Nx+1');
end
I do not hit the error.
Are you sure you don't do something in some intervening code?

1 件のコメント

madhan ravi
madhan ravi 2019 年 9 月 22 日
@the cyclist: I agree with your comment. I just realised right before you commented , so I eliminated my answer. Commenting after seeing your comment in activity feed.

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeOperators and Elementary Operations についてさらに検索

製品

リリース

R2018a

質問済み:

2019 年 9 月 22 日

コメント済み:

2019 年 9 月 22 日

Community Treasure Hunt

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

Start Hunting!

Translated by