Why is my fundamental frequency at the 15th harmonic order
Show older comments
Dear Matlab Community.
I am trying to implement a code to show harmonic content and order in Matlab. my fundamental is supposed to be at harmonic order 1, however the ouput plot I am getting is wrong and I am having difficulies proceeding.
I would really apreciate any help. Thanks
[D,S,R] = xlsread('test data.xls');
v = D(:,2);
Signal = D(:,2);
Ts = 0.00005; % Sampling Interval (seconds)
Fs = 1/Ts; % Sampling Frequency (Hz)
Fn = Fs/2;
%PERFOM FFT
N = length(Signal);
meanSignal = mean(Signal); % ‘Signal’ Mean
FTSignal = fft(Signal-meanSignal)/N;
Fv = linspace(0, 1, fix(numel(FTSignal)/2)+1)*Fn; % Frequency Vector
Iv = 1:numel(Fv); % Index Vector
%Plotting Harmonics (THD)
har_mag = abs(FTSignal(Iv))*2;
figure;
bar(har_mag(1:20),0.4)
xlabel('Harmonic Order','fontsize',10);
ylabel('Voltage (V)','fontsize',10)
hold off
3 Comments
Stephen23
on 5 May 2020
Original question by Jmv, recovered from Google Cache (the uploaded files could not be recovered):
Why is my fundamental frequency at the 15th harmonic order
Dear Matlab Community.
I am trying to implement a code to show harmonic content and order in Matlab. my fundamental is supposed to be at harmonic order 1, however the ouput plot I am getting is wrong and I am having difficulies proceeding.
I would really apreciate any help. Thanks
[D,S,R] = xlsread('test data.xls');
v = D(:,2);
Signal = D(:,2);
Ts = 0.00005; % Sampling Interval (seconds)
Fs = 1/Ts; % Sampling Frequency (Hz)
Fn = Fs/2;
%PERFOM FFT
N = length(Signal);
meanSignal = mean(Signal); % ‘Signal’ Mean
FTSignal = fft(Signal-meanSignal)/N;
Fv = linspace(0, 1, fix(numel(FTSignal)/2)+1)*Fn; % Frequency Vector
Iv = 1:numel(Fv); % Index Vector
%Plotting Harmonics (THD)
har_mag = abs(FTSignal(Iv))*2;
figure;
bar(har_mag(1:20),0.4)
xlabel('Harmonic Order','fontsize',10);
ylabel('Voltage (V)','fontsize',10)
hold off
Rik
on 5 May 2020
Why did you edit away important parts of your question and delete several comments? That is extremely rude.
Rena Berman
on 14 May 2020
(Answers Dev) Restored edit
Accepted Answer
More Answers (1)
Rafael Hernandez-Walls
on 4 May 2020
0 votes
why don't use the FTTSHIFT, this function Shift zero-frequency component to center of spectrum.
Categories
Find more on Spectral Measurements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!