Scaling of time
10 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi,
I've a .mat file with a signal and the time is long 19 seconds by a sampling time of 0.001 seconds. Could I compress these 19 seconds of signal in 1.9 seconds of the same signal?
1 Commento
Sarower Hossain
il 3 Nov 2020
The time scaling operation of a Discrete-time signal with MATLAB coding
Risposte (6)
Paulo Silva
il 21 Giu 2011
load the file and do something like this
Ts=0.001; %signal sampling
t=0:Ts:19; %time vector (in your case it's the first row)
Tss=10; %new sampling
tt=t(1:Tss:end); %take a sample every Tss samples
Your mat file must have the time in the first row and the signal in the second, it's the same procedure for the second line, save the mat file [t;s]
1 Commento
Walter Roberson
il 21 Giu 2011
Warning: if you use t=0:0.001:19; then you might not get the values you expect. For example,
t = 0:0.001:0.010;
t*1000 - round(t*1000)
and notice that entry 10 (corresponding to 0.009) is 1.77635683940025e-15 instead of 0.
Using a decimal fraction in a colon range almost always gives you round off error. Sometimes that does not matter, but it can be a soggy nuisance at times.
Walter Roberson
il 21 Giu 2011
If your data is an exact multiple of the decimation factor, then you may want to use
tt = mean(reshape(t,10,[]));
or perhaps
tt = median(reshape(t,10,[]));
This at least takes the information inside each period in to account rather than just throwing it away.
0 Commenti
Walter Roberson
il 21 Giu 2011
If you have the signal processing toolbox, you may wish to use
tt = decimate(t, 10);
0 Commenti
Gurudatha Pai
il 21 Giu 2011
I am of the opinion that the question and solutions offered here don't match. Your question seems to be of a compression. However, I don't see how you can compress a signal from 19s to 1.9s (or at least it is not clear to me) .
What everybody has suggested is some version of down-sampling and a corresponding decrease of sampling frequency. And hence, the signal length in time is still 19s but it has less number of samples, obviously.
If your question is to say, play an 19s audio file in 1.9s, you could just increase your sampling frequency in
wavplay(y, fs)
to
wavplay(y,10*fs)
In effect, you have played a 19s signal in 1.9s. (Does it make sense to do that, is perhaps defined by your problem at hand)
2 Commenti
Walter Roberson
il 21 Giu 2011
Decimation and down-sampling are forms of lossy compression, and in some circumstances might be as acceptable as (for example) using JPEG compression.
Gurudatha Pai
il 22 Giu 2011
yes, agreed. Still down-sampling cannot make a signal from 19s to 1.9s! It reduces the number of samples, yes that is compression in terms of memory but not time!
Walter Roberson
il 21 Giu 2011
dwt (discrete wavelet transforms) might be another mechanism for reducing the data to 1/10th of the original while still maintaining the characteristic signal shapes.
0 Commenti
cyberdyne
il 21 Giu 2011
1 Commento
Walter Roberson
il 21 Giu 2011
As you have not given us any information about what the simulation _does_, all we can suggest is that you buy a faster system, such as at http://www.liquidnitrogenoverclocking.com/ .
With the information you have given us so far we have to assume that every sample makes a significant difference to the state of the simulation.
Vedere anche
Categorie
Scopri di più su Multirate Signal Processing 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!