im trying to chop my signal so it only plots 1 second but any second I have choosen as the length of the signal is 10 seconds

3 次查看(过去 30 天)
t1=load('201710h1.lvm'); %test 1
t2=load('201710h2.lvm'); %test 2
Fs = 100000; % frequency sample
x = t1 (:,1); % time for test 1
sin = t1 (:,2); % test 1 sesnor 1
plot(sin)
title('Sensor1')

回答(2 个)

Star Strider
Star Strider 2021-1-3
First, please do not name the variable ‘sin’ since that makes the sin() function useless. This is called ‘overshadowing’ and is to be avoided.
Second, see if the buffer function will do what you want, with respect to segmenting your signal.

Walter Roberson
Walter Roberson 2021-1-3
x = t1(1:Fs,1);
sen1 = t1(1:Fs,2);
plot(x, sen1)
title('Sensor1')
or
idx = find(t1(:,1) <=1, 'last');
x = t1(1:idx,1);
sen1 = t1(1:idx,2);
plot(x, sen1)
title('Sensor1')
  2 个评论
Walter Roberson
Walter Roberson 2021-1-4
Yes it does chop the signal, showing two different ways of chopping the signal.
When your fs is accurate, then 1:Fs takes 1 second of data.
When your time vector is accurate, then finding the place where the time is last no more than 1 second and taking the samples to there takes the first 1 second of data, even if the data is sampled at irregular intervals. (Exception: if you have negative time, the code as written does not remove the samples corresponding to negative time.)

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Spectral Measurements 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by