I did make an code of fast fourier transform. But there's an error on the code when I run it. There's anyone who more about and can assist or guide me to make the code running

1 visualización (últimos 30 días)
I did make a code of FFT(fast fourier transform) using excel dataset (2049*7) as first column is taken as time and 2.3 and 4 as voltage A, B and C' and the 5,6 and 7 columns as currents A,B,C. When I run the code it give me error.
" Unrecognized function or variable 'Window_Nh'.
Error in fft_analyser(line 17)
Window_data = repmat(Window_Nh, 1, 7); % Replicate the window for 7 columns"
Below is half of the code that are note working
data = readtable('sadieldata.xlsx'); % load data
fs = 1000; % Sampling frequency
T = 1/fs; % Sampling period
N = 2049; % Number of samples
t = (0:N-1)*T; % Time Vector
U1 = data(:,1); % read phase 1 voltage
U2 = data(:,2); % read phase 2 voltage
U3 = data(:,3); % read phase 3 voltage
i1 = data(:,4); % read phase 1 current
i2 = data(:,5); % read phase 2 current
i3 = data(:,6); % read phase 3 current
%w = hann(N); % apply window function
Nh = 1:N; % number of windows for Hann Window
Nhr = rot90(Nh); % rotated window vector
data = rand(N, 7); % data of size N x 7; % Create a Hanniing window for each column
Window_Nhr = hann(N); % create a hanning window of length N
Window_data = repmat(Window_Nh, 1, 7); % Replicate the window for 7 columns
Window_rot = zeros(N, 7); % rotate Window vector to perform multiplication
for i = 1:size(Window_data, 2) % Iterate over columns
% Rotate the column by 90 degrees counterclockwise
Window_rot(:, i) = rot90(Window_data(:, i));
end

Respuesta aceptada

Walter Roberson
Walter Roberson el 14 de Mzo. de 2024
You define a variable Window_Nhr but then you try to repmat Window_Nh
  3 comentarios
Walter Roberson
Walter Roberson el 15 de Mzo. de 2024
N = 2049; % Number of samples
That is a constant size
U1 = data(:,1); % read phase 1 voltage
That depends on the size of the input
Window_rot = zeros(N, 7); % rotate Window vector to perform multiplication
That is the constant size, by 7
U1_hann = U1.*Window_rot;
That attempts to multiply the variable-length data, by 2049 x 7 array. That will fail if the input data does not happen to be 2049 long.
Walter Roberson
Walter Roberson el 15 de Mzo. de 2024
What you probably need to do is
U1 = data{:,1};
Overlap_size = 64; %NEEDS TO BE ADJUSTED
buffered_U1 = buffer(U1, N, Overlap_size);
Window_Nhr = hann(N);
hanned_U1 = Window_Nhr .* buffered_U1;

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Spectral Measurements en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by