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

7 visualizzazioni (ultimi 30 giorni)
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')

Risposte (2)

Star Strider
Star Strider il 3 Gen 2021
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 il 3 Gen 2021
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 Commenti
Walter Roberson
Walter Roberson il 4 Gen 2021
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.)

Accedi per commentare.

Categorie

Scopri di più su Measurements and Feature Extraction in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by