Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

matlab, obtaining frequency spectrum for uneven time series

Status
Not open for further replies.

menik

Newbie level 3
Newbie level 3
Joined
May 5, 2013
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Visit site
Activity points
1,305
Hi all,
I am using fft to draw a spectrum. I already got results for fft(). But my problem is the data recorded time series is uneven.

like,
6.00E-05
7.06E-05
8.18E-05
9.37E-05
1.06E-04
1.20E-04
1.34E-04
1.49E-04

So, could you pls help me to get frequency?

Sampling frequency: Fs=1366
Used fft length: nfft=2048
 

this means you are using a complex fft.... if you want an even fft output, you need to make sure that you have real inputs.
can you post:
1. your complete input
2. matlab commands you are using
3. output data

or a screenshot
 

Hi Hassan, Thanks a lot for the reply.
I have done fft using integration of data to even time slots. I want to know whether it is correct or not. I have seen nonuniform DFT can be used, but don't know how to write codes. pls consider I am not familiar with matlab.

01. I'll post part of it.

format long
A=[0.000010 0.115949
0.000020 0.115362
0.000030 0.115218
0.000040 0.115354
0.000050 0.115492
0.000060 0.115604
0.000071 0.115685
0.000082 0.115742
0.000094 0.115778
0.000106 0.115797
0.000120 0.115803
0.000134 0.115801
0.000149 0.115793
0.000165 0.115777
0.000182 0.115759];

02. Fs=(A:),1)); %size=1385
n=0:0.227493;
nn=0:1E-5:0.227493;
XX=interp1(A:),1),A:),2),nn);

N=2048;
R2=A:),2);
X=fft(R2,N);
mX=abs(X);
fc=[0:FS/N:FS-1/N];
loglog(fc,mX),grid
 

First of all your data needs to have 2^n samples for FFT... you have provided 15, so i have added 1 more to make it 16.
The main thing you were missing was "FFTSHIFT()"

try the following code and see the attached pic for results.

Code:
clear all; close all; clc;
A=[0.000010 0.115949
0.000020 0.115362
0.000030 0.115218
0.000040 0.115354
0.000050 0.115492
0.000060 0.115604
0.000071 0.115685
0.000082 0.115742
0.000094 0.115778
0.000106 0.115797
0.000120 0.115803
0.000134 0.115801
0.000149 0.115793
0.000165 0.115777
0.000182 0.115759
.000182+(.000182-.000165), .115759-(.115777-.115759)];

FS=(A(:,1)); %size=1385
n=0:0.227493;
nn=0:1E-5:0.227493;
XX=interp1(A(:,1),A(:,2),nn);

N=16;
R2=A(:,2);
X=fft(R2,N);
mX=abs(fftshift(X));
%fc=[0:FS/N:(FS-1)/N];  <--- what is this line??? Not using this, see next line
fc=FS/N; 
loglog(fc,mX),grid

untitled.png
 

Can you please explain me the meaning of FS/N??
 
Last edited:

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top