Creating time vector using number of samples
Show older comments
I have the following parameters:Total number of samples: 5000, samplerate: 2500.I created my time vector as usual: t=0:1/2500:5000-1/2500. But the time vector is a lot bigger than my related data vector which makes plotting impossible. Am I misunderstanding the meaning of sample number?
Accepted Answer
More Answers (1)
Aniruddh Maini
on 2 Jul 2022
0 votes
Hi Lina
As per your question NumSamples = 5000 and SampleRate = 2500
That means, in one seconds the signal will be sampled 2500 times or we will get 2500 samples each second, and we have to get 5000 samples in total.
So let's say
At t = 0 sec we get a sample
At t = 0 + (1/2500) we get another sample
At t = 0+(1/2500)+(1/2500) we get another sample.
and so on...
So from the observation we can say that total time required to get 5000 samples is (1/2500)*(5000-1)
Since we are getting 5000 samples between t = 0 and t = (1/2500)*(5000-1), so the SampleTime vector can be found as
timeVector = 0:1/2500:(1/2500)*(5000-1) or alternatively as
timeVector = linspace(0,(1/2500)*(5000-1),5000)
Hope it helps.
Categories
Find more on Logical 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!