Scaling of time

조회 수: 34 (최근 30일)
cyberdyne
cyberdyne 2011년 6월 21일
댓글: Sarower Hossain 2020년 11월 3일
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