Filtering with Discrete transfer functions in matlab

Click For Summary

Discussion Overview

The discussion revolves around the challenges of implementing discrete transfer functions in MATLAB for filtering signals, particularly in the context of impedance spectroscopy data from electrodes. Participants explore the modeling of transfer functions for circuits involving resistors and capacitors, and the application of FFT and IFFT in signal processing.

Discussion Character

  • Technical explanation
  • Exploratory
  • Debate/contested

Main Points Raised

  • One participant describes their approach to modeling the transfer function of electrodes connected to an amplifier, expressing concern about the validity of their results when applying FFT and IFFT.
  • Another participant suggests that the issues may stem from MATLAB's handling of FFT, proposing a method to correct the orientation of the FFT output using fftshift and ifftshift.
  • A third participant mentions the complexity of modeling a Constant Phase Element (CPE) and references theoretical resources for understanding CPEs and equivalent circuits.
  • One participant highlights the periodicity of the Discrete Fourier Transform (DFT) and discusses MATLAB's indexing limitations, which may affect the interpretation of frequency data.

Areas of Agreement / Disagreement

Participants express differing views on the effectiveness of their approaches and the implications of MATLAB's FFT implementation. No consensus is reached regarding the best method for filtering or modeling the circuits discussed.

Contextual Notes

Participants note limitations related to the complexity of the equivalent circuits, particularly for CPEs, and the challenges posed by MATLAB's indexing and FFT behavior. These factors contribute to the uncertainty in achieving accurate filtering results.

Who May Find This Useful

This discussion may be useful for individuals working on digital signal processing, particularly those dealing with impedance spectroscopy and circuit modeling in MATLAB.

gandrin
Messages
2
Reaction score
0
Got a DSP problem. I think this is a bit complicated, and may need some DSP gurus to answer it. I've been banging my head on this literally for months now. Thought I had it figured out, but today find I'm still not done.

I have some Impedance spectroscopy data from electrodes, sampled at discrete frequencies. I want to model the transfer function that these electrodes form when connected in series to an amplifier (a simple R||C cct).

The goal is to multiply that discrete transfer function with the FFT(signal), then take IFFT(Product) to show what the amplifier actually sees.

My first inclination was to do the following:

(note: this is a voltage divider across one impedance [ R_amp||C_amp ] that is in series with Z_electrode)

Z_amp= R/sC / (R + 1/sC)
Z_amp= R / (sRC + 1)
Z_divider=Z_amp/(Z_amp + Z_electrode)
Z_divider = R./(R + (Z_electrode .* (1+sRC)))
so now I took the leap of faith...
w=1:1:100000; % the frequencies at which Z_electrode was sampled
Z_divider = R./ (R + (Z_electrode(w) .* (1 + iwRC)));

Then
Y=fft(signal).*Z_divider
filtered_signal=real(ifft(Y));

This gives a reasonable answer...but I'm worried it's false. The reason why is because when I do the same process with just an RC circuit (in this case a generic low-pass RC config), the answer is not right...

RC=1e-5;
Z_lowpass = 1./ (1 + iwRC);

The resulting "filter" was junk, not holding a DC voltage and "anticipating" voltage changes.

signal= ones(1,100000);
signal(50000:70000)=100;
Y=fft(signal);
ZY=Z_lowpass.*Y;
plot(real(ifft(ZY)))
hold
plot(signal,'r')

So I have two questions.

1. I have figured out the coefficients for that lowpass filter
k=deltaT/ (RC + deltaT)
filter([0 k], [1 -(1-k)], signal)

That was NOT EASY to figure out, though wikipedia gave guidance for this particular cct.

So is there an easier way to do that with other circuits in Matlab?


2. So how do I implement this filtering function in the Z_divider example above? How can I "discretize" my RC cct to be able to voltage divide with my electrode Impedance Spectroscopy? ( I do have an equivalent cct for the electrode, but it's a Constant Phase Element, and essentially impossible to figure out analytically.)
 
Physics news on Phys.org
I think I've solved my own problem. The problem was the bizarre way MATLAB does FFT. I redid it with the following:

L=100000;
Fs=###;
w_filter=[-L/2:L/2-1]*Fs/L; % have to evaluate the function from -Fs/2:Fs/2-1

Z_lowpass = 1./ (1 + iw_filter*RC);

signal= ones(1,100000);
signal(50000:70000)=100;
Y=fft(signal);

%here's the key--fix the strange Matlab orientation
Y_shift=fftshift(Y);

ZY=Z_lowpass.*Y_shift;
ZY_unshift=ifftshift(ZY);
plot(real(ifft(ZY_unshift)))
hold
plot(signal,'r')
 
gandrin said:
I do have an equivalent cct for the electrode, but it's a Constant Phase Element, and essentially impossible to figure out analytically.
Hi !
On a theoretical viewpoint, CPE can be figured out as shown in the paper "The Phasance Concept" published on Scribd.
For practical applications, many equivalent networks can be derived and used to model real electrical components. For example: "Theoretical impédances of capacitive électrodes" published on Scribd :
http://www.scribd.com/JJacquelin/documents
 
the thing you got to remember about the DFT (this is not anything about MATLAB per se) is that it has an inherent periodicity. so the last half of the data (which precedes the first half of the repeated cycle of the same data) can be thought of as the "negative frequency" or the "negative time" data that precedes the first half. MATLAB's fftshift() is just meant to swap the last half with the first so that it looks like the negative frequencies precede the positive frequencies.the other dumb thing MATLAB does is insist that all indices are positive integers. 0 or negative integer indices are not allowed in MATLAB which is unfortunate since there is so much literature, especially in DSP, that has non-positive indices.
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 11 ·
Replies
11
Views
4K
  • · Replies 8 ·
Replies
8
Views
3K
Replies
2
Views
10K
  • · Replies 1 ·
Replies
1
Views
6K
  • · Replies 16 ·
Replies
16
Views
2K
  • · Replies 14 ·
Replies
14
Views
25K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
9K
  • · Replies 2 ·
Replies
2
Views
26K