So for my project, I am measuring heartbeat of a person in a span of 10s. However, as the number of heartbeats may differ for each person, is it wise to use a vector?
No, you don't want a vector, for a number of reasons:
- There is no "vector" unless you add extra (unsupported) code.
- Vectors use dynamic memory. Arduinos don't work well with dynamic memory.
- It's pointless anyway.
Just allocate an array big enough to contain enough timestamps. In a 10 second period, if you get more than 100 beats, the person you are measuring the heart rate of is most likely in a noticeably "unfortunate" state. That's 600bpm. That's entering panicked mouse territory.
Even with that extreme number of beats an array of 100 32-bit values is only 400 bytes.