how to get fft analysis data from power gui to command and hence to exce;

10 visualizaciones (últimos 30 días)
Niraj Acharya
Niraj Acharya el 23 de Sept. de 2019
Respondida: Rahul el 12 de Ag. de 2025
Hey guys,
I am tring to export the fft analysis result from fft tools in power gui to excel. I have 4 input signal available and 3 signal number (i.e. it is a 3 phase sytem with 4 different currents). I tried to export it to MATLAB command window using following command.
FFTDATA = power_fftscope(Currents);
FFTDATA.startTime=0.25;
FFTDATA.cycles = 1;
FFTDATA.fundamental = 50;
FFTDATA.maxFrequency = 2050;
FFTdata.input=3;
>> FFTDATA = power_fftscope(FFTDATA)
FFTDATA =
(%struct with fields:
time: [60001×1 double]
signals: [1×4 struct]
blockName: 'Three_phase_PV_Mod_2018a_correct/Currents'
input: 1%First input
signal: 1% First signal
startTime: 0.2500
cycles: 1
fundamental: 50
maxFrequency: 2050
THDmaxFrequency: Inf
THDbase: 'fund'
freqAxis: 'Hertz'
mag: [41×1 double]
phase: [41×1 double]
freq: [41×1 double]
THD: 8.0498
samplingTime: 5.0000e-06
samplesPerCycle: 4000
DCcomponent: 1.0374
magFundamental: 26.8804)
FFTDATA.mag
FFTDATA.phase
FFTDATA.freq
However, I get magnitude, phase and frequency for 1st input and 1st signal only (as indicated by comment in the result above). How can I get data for other combinations? For example, 2nd signal 3rd inout and so on.

Respuestas (1)

Rahul
Rahul el 12 de Ag. de 2025
Hi Niraj,
I understand that you are working with the 'power_fftscope' function to extract FFT analysis results from 'Powergui' in a 'three-phase' system, and are facing challenges in accessing data for multiple 'inputs' and 'signals'. From the details provided, it appears that the current workflow extracts results only for the 'first input' and 'first signal' combination because 'power_fftscope' processes one channel at a time.
In such cases, the 'input' and 'signal' fields within the 'FFTDATA' structure can be iteratively updated to cover all required combinations. The process typically involves the following steps:
  1. Running 'power_fftscope' for the desired 'blockName'.
  2. Modifying 'FFTDATA.input' and 'FFTDATA.signal' in a loop to cycle through each available input and signal.
  3. Exporting the 'mag', 'phase', and 'freq' values for each combination to a file (e.g., Excel).
For example:
% Define block name from your model
blockPath = 'Three_phase_PV_Mod_2018a_correct/Currents';
% Get initial FFTDATA struct
FFTDATA = power_fftscope(blockPath);
% Configure general parameters
FFTDATA.startTime = 0.25;
FFTDATA.cycles = 1;
FFTDATA.fundamental = 50;
FFTDATA.maxFrequency = 2050;
% Loop over inputs and signals
numInputs = numel(FFTDATA.signals); % Usually matches no. of available inputs
numSignals = numel(FFTDATA.signals(1).values); % Signals per input
allResults = {};
for inIdx = 1:numInputs
for sigIdx = 1:numSignals
FFTDATA.input = inIdx;
FFTDATA.signal = sigIdx;
result = power_fftscope(FFTDATA);
% Store or export data
allResults{end+1} = table(result.freq, result.mag, result.phase, ...
'VariableNames', {'Frequency_Hz', 'Magnitude', 'Phase_Deg'});
% Example: write to Excel
filename = sprintf('FFT_Input%d_Signal%d.xlsx', inIdx, sigIdx);
writetable(allResults{end}, filename);
end
end
By iterating through 'input' and 'signal' values, data for all available channels can be retrieved without restriction.
You can refer to the following documentation links for more information regarding exporting and power FFT of signals:

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by