Hi guys,
I have vector x that goes between 0 and 7, with an increment of 0.1.
x = 0:0.1:7
I want to be able to know how many increments I have at say when x = 3, The answer is 31, but could I make use of any function in MATLAB to calculate this?
Many thanks,
Scott

 採用された回答

Torsten
Torsten 2025 年 8 月 5 日
移動済み: Torsten 2025 年 8 月 5 日

0 投票

x = 0:0.1:7;
numel(x(x<=3))
ans = 31

2 件のコメント

Scott Banks
Scott Banks 2025 年 8 月 5 日
Thanks, Torsten!
Torsten
Torsten 2025 年 8 月 5 日
Or:
x = 0:0.1:7;
nnz(x<=3)
ans = 31

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange で MATLAB についてさらに検索

質問済み:

2025 年 8 月 5 日

コメント済み:

2025 年 8 月 5 日

Community Treasure Hunt

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

Start Hunting!

Translated by