Impedance calculation using FFT from time, voltage and current battery data

80 views (last 30 days)
I have battery pulse test and pseudo OCV measurements (time, current and voltage) in time domain and I want to obtain plot similar to EIS in freuqnecy domain using Fourier Transform.
Is it possible? If yes, then please explain the approach
  1 Comment
ekagra gupta
ekagra gupta on 23 Aug 2022
? I know using FFT but it would be great if someone would rpovide some code to follow up

Sign in to comment.

Accepted Answer

Mathieu NOE
Mathieu NOE on 24 Aug 2022
should be possible using tfestimate function
alternative (older) code :
x and y are your time domain data (x = input of the system , y = output)
you need to specify the fft buffer length, sampling freq, type of window and overlap (if you want)
function [Txy,Cxy,f] = mytfe_and_coh(x,y,nfft,Fs,window,noverlap)
% Transfer Function and Coherence Estimate
% compute PSD and CSD
window = window(:);
n = length(x); % Number of data points
nwind = length(window); % length of window
if n < nwind % zero-pad x , y if length is less than the window length
x = x(:); % Make sure x is a column vector
y = y(:); % Make sure y is a column vector
k = fix((n-noverlap)/(nwind-noverlap)); % Number of windows
% (k = fix(n/nwind) for noverlap=0)
index = 1:nwind;
Pxx = zeros(nfft,1);
Pyy = zeros(nfft,1);
Pxy = zeros(nfft,1);
for i=1:k
xw = window.*x(index);
yw = window.*y(index);
index = index + (nwind - noverlap);
Xx = fft(xw,nfft);
Yy = fft(yw,nfft);
Xx2 = abs(Xx).^2;
Yy2 = abs(Yy).^2;
Xy2 = Yy.*conj(Xx);
Pxx = Pxx + Xx2;
Pyy = Pyy + Yy2;
Pxy = Pxy + Xy2;
% Select first half
if ~any(any(imag([x y])~=0)) % if x and y are not complex
if rem(nfft,2) % nfft odd
select = [1:(nfft+1)/2];
select = [1:nfft/2+1]; % include DC AND Nyquist
Pxx = Pxx(select);
Pyy = Pyy(select);
Pxy = Pxy(select);
select = 1:nfft;
Txy = Pxy ./ Pxx; % transfer function estimate
Cxy = (abs(Pxy).^2)./(Pxx.*Pyy); % coherence function estimate
f = (select - 1)'*Fs/nfft;

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!