Bar plot command to get results same as in PowerGUI FFT analysis bar (relative to fundamental)

10 views (last 30 days)
I want generate from command(.m file) same bar plot as in I see in PowerGUI FFT
can any one provide script?
from figure I can get only
function createfigure(xvector1, yvector1)
%CREATEFIGURE(xvector1, yvector1)
% XVECTOR1: bar xvector
% YVECTOR1: bar yvector
% Auto-generated by MATLAB on 27-Aug-2022 22:17:18
% Create figure
figure1 = figure('Name','FFT Analysis Results');
% Create axes
axes1 = axes('Parent',figure1,...
'Position',[0.117216117216117 0.11530064072437 0.815018315018315 0.805896805896806]);
hold(axes1,'on');
% Create bar
bar(xvector1,yvector1,'BarWidth',0.5);
% Create ylabel
ylabel('Mag (% of Fundamental)');
% Create xlabel
xlabel('Harmonic order');
% Create title
title('Fundamental (50Hz) = 1.608 , THD= 20.67%');
% Uncomment the following line to preserve the X-limits of the axes
% xlim(axes1,[-2.5 50]);
% Uncomment the following line to preserve the Y-limits of the axes
% ylim(axes1,[0 11.443947243101]);
box(axes1,'on');
grid(axes1,'on');
% Set the remaining axes properties
set(axes1,'XMinorGrid','on','YMinorGrid','on','ZMinorGrid','on');

Answers (2)

William Rose
William Rose on 27 Aug 2022
What is this for? I ask because I have been guilty of providing too much assistance on this site to people who are seeking help doing their homework. I am not familiar with powerGUI FFT.
Have you looked at thd? Does it not do what you need? Read the help page for it carefully, to understand it. Notice the optional form
[r,harmpow,harmfreq] = thd(___)
which will interst to you.
The function you included in your posting requires two vector inputs. They must be of equal length. xvector should be the vector of harmonic number, from 0 to the maximum value of interest, and yvector should be the power at each harmonic, expressed as a % of the power in the fundamental. The function generates a title which assumes that fundamental freq=50Hz, THD=20.67%, etc. Those values will probably not be true for you, so you should adapt the funciton to use the correct values for your data.
Good luck!

Alvaro Zarate
Alvaro Zarate on 1 Sep 2023
Use the function power_fftscope()

Community Treasure Hunt

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

Start Hunting!