Scaling of time

10 次查看(过去 30 天)
cyberdyne
cyberdyne 2011-6-21
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 个评论
Sarower Hossain
Sarower Hossain 2020-11-3
The time scaling operation of a Discrete-time signal with MATLAB coding

请先登录,再进行评论。

回答(6 个)

Paulo Silva
Paulo Silva 2011-6-21
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 个评论
Walter Roberson
Walter Roberson 2011-6-21
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
Walter Roberson 2011-6-21
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.

Walter Roberson
Walter Roberson 2011-6-21
If you have the signal processing toolbox, you may wish to use
tt = decimate(t, 10);

Gurudatha Pai
Gurudatha Pai 2011-6-21
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 个评论
Walter Roberson
Walter Roberson 2011-6-21
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
Gurudatha Pai 2011-6-22
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
Walter Roberson 2011-6-21
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.

cyberdyne
cyberdyne 2011-6-21
I'm searching for a way to make simulation time shorter
  1 个评论
Walter Roberson
Walter Roberson 2011-6-21
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Multirate Signal Processing 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by