Counting the number of increments in a vector

3 views (last 30 days)
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

Accepted Answer

Torsten
Torsten on 5 Aug 2025
Moved: Torsten on 5 Aug 2025
x = 0:0.1:7;
numel(x(x<=3))
ans = 31

More Answers (0)

Categories

Find more on Shifting and Sorting Matrices in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!