30 views (last 30 days)

Honglei Chen
on 30 Mar 2011

Hi Cesare,

If I understand your question correctly, your problem is more related to why MATLAB wrap the data, the particular length is just a specific case. I'll try to explain the reason for wrapping the data.

The calculation of signal spectrum, such as periodogram, uses FFT internally, where the length of FFT is denoted as NFFT. In theory, when using FFT, the signal in both time domain and frequency domain are discrete and periodic, where the period is given by NFFT. Hence, if you specify an NFFT that is less than the signal length, it actually introduces the aliasing in the time domain and make the signal (even if its length is N>NFFT) periodic with NFFT. When you take FFT of this sequence, you are working with this aliased sequence. This is what datawrap do for you.

For example, if you have a sequence 1 2 3 4 5, assuming that your period is also 5, you have

1 2 3 4 5

1 2 3 4 5

1 2 3 4 5

--------------------------------

... 1 2 3 4 5 ...

i.e., your original series. Now assume you have a period of 3, then it looks like

1 2 3 4 5

1 2 3 4 5

1 2 3 4 5

------------------------

... 5 7 3 ...

A sequence that is wrapped around and has only a length of 3. Note that

>> datawrap(1:5,3)

ans =

5 7 3

HTH.

Cesare
on 28 Feb 2012

Honglei Chen
on 28 Feb 2012

Zeeshan Salam
on 5 Nov 2019

how i wrap these two curves?

%define x for both curves

x_ref = 0:0.01:1;

x = 0:0.01:1;

%define the reference curve and the other curve

c_ref = sin(x_ref*2*pi);

y = 0.5+0.5*sin(x*2*pi);

%plot both curves

figure(1)

plot (x_ref,c_ref,'r');

hold on

plot(x,y,'b');

axis([min(x_ref)-1,max(x_ref)+1,min(c_ref)-1,max((c_ref))+1]);

legend('c_{ref}','y')

Opportunities for recent engineering grads.

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

Start Hunting!
## 1 Comment

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/4114-datawrap#comment_8293

⋮## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/4114-datawrap#comment_8293

Sign in to comment.