0
$\begingroup$

I am trying to plot the step response of an electronic circuit(differentiator) using MATLAB but I get an error:

Error using DynamicSystem/step (line 95)
Cannot simulate the time response of models with more
zeros than poles.

My code is below:

R=47*10^3%resistance value
C=1*10^-6% capacitor value
den=[-1]%denominator of transfer function
num=[R*C 0]%numerator of transfer function
sys=tf(num,den)%transfer function expression of model/system
step(sys)%step response

How can I plot the step response without changing the original transfer function? If I change the original transfer function, it will become a new system, but I want to analyze the original system.

Based on the currently given answer, I have also included a snapshot of the Simulink block diagram, mainly the scope. The derivative of the unit step has a very high value, more than 15x10^13 as shown in the attached snapshot. The top plot shows the derivative of the unit step while the bottom graph shows the original unit step signal.

enter image description here enter image description here

$\endgroup$
2
  • 2
    $\begingroup$ Is it a passive RC or an active one? If it's active then, in practice, you will always have a pole from the opamp so the transfer function will be proper. If it's passive then you will get a pole from the I/O impedances and, again, the t.f. will be proper. $\endgroup$ Sep 19, 2022 at 7:53
  • 1
    $\begingroup$ The derivative of step function is infinite (it's a Dirac delta). What else would you expect ? $\endgroup$
    – Hilmar
    Sep 19, 2022 at 12:41

3 Answers 3

1
$\begingroup$

You are using the wrong denominator, for a differentiator.

In MATLAB :

 clear all;close all;clc

R=47000 %[ohm] 
C=1*10^-6 % [F]
d1=R*C

h1=tf([d1 0],[d1 1])

t=[0:d1/10:20*d1]; % [s]

figure % step response of basic differentiator
step(h1,t)
grid on
title('C R series circuit, reading R')

enter image description here

h2=tf([0 1],[d1 1]) 

figure  % step response of basic integrator
step(h2)
grid on
title('R C series circuit, reading C')

enter image description here

If you find this answer useful would you please be so kind to consider clicking on accepted answer?

Thanks for reading my answer.

$\endgroup$
2
$\begingroup$

The transfer function you use is the one of an ideal differentiator, not of a practical one. So your system has a pole at infinity and the system is unstable. That's why Matlab can't plot the step response. Think about it, what do you get when you try to differentiate an ideal step function?

$\endgroup$
5
  • $\begingroup$ How we can convert this ideal differentiator into a practical one? Please also share MATLAB code if possible please $\endgroup$
    – DSP_CS
    Sep 19, 2022 at 10:45
  • $\begingroup$ I have also updated my question with more details and included snapshot of simulink"try to differentiate an ideal step function" $\endgroup$
    – DSP_CS
    Sep 19, 2022 at 11:10
  • $\begingroup$ @engr: So you have your plot of the step function, sort of. What is it that you don't like about it? $\endgroup$
    – Matt L.
    Sep 19, 2022 at 11:31
  • $\begingroup$ @MattL.: "...and the system is unstable...". There's a war going on in my head right now, with teams of neurons pushing "no, it's stable, it just pops to infinity once", and "yes, it's unstable because BIBO". If that gets resolved without too many deaths, I'll be smarter coming out the other side. (But I'd argue that there ought to be a definition of stability that encompasses this). $\endgroup$
    – TimWescott
    Sep 19, 2022 at 17:10
  • 1
    $\begingroup$ @TimWescott: It indeed depends on what definition of stability you're using. The ideal differentiator is BIBO-unstable, but I'd argue that it's marginally stable (just like the ideal integrator). $\endgroup$
    – Matt L.
    Sep 19, 2022 at 20:28
1
$\begingroup$

Your problem is that you're trying to simulate a block who's transfer function is improper -- i.e., it has a leading term of $s^n$, $n > 0$.

You can express the step response of such a system by tossing in some Dirac delta functions -- i.e. if $H(s) = as + \cdots$, then $\mathcal L^{-1}\frac{H(s)} s = a\delta(t) + \cdots$, and higher-order derivatives would leave higher-order Dirac deltas (i.e., $\int \delta_n(t) dt = \delta_{n-1}(t)$, and the "plain old" Dirac delta is the zero-order Dirac: $\delta(t) := \delta_0(t)$).

But typical numerical simulators don't handle Dirac deltas (nor, for that matter, does the real world).

Looked at another way, the real world doesn't have naked differentiators. All real-world processes are low-pass in nature. You may end up modeling a real-world process as a differentiator, but at some point that model will break down.

Generally, if you find that you have a transfer function in your model that looks like $H(s) = s + \cdots$, then you need to band-limit the derivative. At the very least, $H'(s) = \frac{H(s)}{\tau s + 1}$, where $\tau$ is just big enough to make things work.

Better, figure out why your physical model contains a derivative block, and see if you can replace that derivative with something more realistic.

Alternately, you may have -- consciously or by following someone's treatment in a paper or book -- added a derivative as some sort of a block-diagram analysis trick. If that's the case, for a physical simulation, you need to unwind that trick, and simulate something closer to reality.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.