Continue to Site

Welcome to

Welcome to our site! is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

sample-and-hold circuit simulation in MATLAB

Not open for further replies.


Newbie level 5
Nov 26, 2008
Reaction score
Trophy points
Activity points
Does anyone have ideas about how to simulate a sample-and-hold circuit using MATLAB code (not simulink)? The model I have is
Vo = Vi + (a0+a1*Vi+a2*Vi^2)*(dVo/dt).
I don't know how to derive the solution of Vo to model it? Thank you in advance.

you need not solving the "differential equation", since it is not one!
The model is simply telling you that the output of the SHA is non-linear and it is giving some coefficients. The term "dt" is your sampling period and "dVo" is the difference Vo(n)-Vo(n-1).


    Points: 2
    Helpful Answer Positive Rating
thank you very much! i will have a try.

Added after 33 minutes:

Hi, JoannesPaulus, I have another question. If "dVo" can be regarded as Vo(n)-Vo(n-1), then how can I get Vo(n) from a set of Vi(n) since I don't know the Vo(n-1) especial when n=1. Thanks!

If I understand correctly, what you are trying to do is a linear interpolation of your input, adding some distortion to model the effect of the non-linearity in the sample and hold circuit. So,
Vo(n)=Vo(n-1)+(Vi(n)-Vi(n-1))*dVo/dt is your linear interpolation, for n=2,... and Vo(1)=0;
The problem is how to model dVo, which is the local derivative of your signal. In the ideal SHA Vo(n)=Vi(n) and therefore dVo(n)=dVi(n) (but only at the sampling times). This is the easiest approximation.

I think you might be better off code-modeling the various
functions and artifacts of interest, in a more straightforward
and expressive way. Why would you want to do it using
polynomial math, when you can talk sample time and slope
error, sample pedestal, through-delay and rise-fall? I bet
there's an elegant one-liner that's like a koan or something,
if you only wanted the event value and not the details.

There's probably verilog-a code out there already that you
could dig up, rip up and turn into MATLAB or whatever.

Not open for further replies.

Part and Inventory Search

Welcome to