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.

find fft of AC variable load in MATLAB

Status
Not open for further replies.

nishat anjum khan

Member level 2
Joined
Aug 4, 2012
Messages
44
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,562
Hi everybody..i am working with a project where i have to work with real time data...i am using variable ac load and via Arduino i plot real time voltage and current in matlab...then i take some samples at a time and do fft of it in MATLAB..we are working with 50Hz system but i can't found harmonic in 50Hz...what should i do to get it? i am attaching my code..please help someone...plzzz
 

Attachments

  • Desktop.rar
    16.8 KB · Views: 80

Your code is extremely badly formatted and difficult to read. There are numerous variables defined that are never used. There are numerous initial values that are never used. Indentation is all over the place.

That code can comfortably be reduced to under 20 lines. Please tidy it up so it is easier for anyone to help (and for you to understand).

In my opinion, your first few lines should be:
Code:
close all; clear all; clc;

% Open Serial COM Port
s = serial('COM1','Baudrate',57600);

The rest of your initialisation is unnecessary. I also think lines 44 - 86 can be removed.

I don't think you should be using tic and toc for timing. You have a known baud rate, so you should be using this to determine your sampling frequency, fs. Then, in your N-sample FFT, you know the bin spacing is fs/N.

From this, you will find the true frequency of any harmonic.
 

thank u very much for your reply..i will rearrange my code...can u just tell me how can i determine sampling frequency from baud rate?
 

thank u very much for your reply..i will rearrange my code...can u just tell me how can i determine sampling frequency from baud rate?
Assuming you are receiving a constant stream of data, the relationship is direct, so you can figure it out yourself. Here is a definition of Baud rate: [link] and here is a definition of sampling rate: [link].

If you do not have a constant stream of data (and, instead, the data arrives at irregular intervals), then the FFT cannot be used directly anyway. Hopefully, this is not the case.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top