# Is it possible to create a signal in LTSpice by using a stored data?

I have lots of sampled voltage signals data where I can plot them in MATLAB or write them to a text file for each sample.

I would like to use these samples to generate input signals in LTSpice instead of trying to mimic them.

Is it doable in LTSpice?

edit: My data samples on txt can be in the following format:

59.7435 5.0615

59.7437 5.0578

59.7440 5.0768

59.7443 5.1119

Where the first column is time stamps in seconds, and the second column is corresponding sampled voltages

If you can format the matlab data as a series of timestamps and levels you can use the PWL file option for a voltage or current source.

http://www.linear.com/solutions/1814

• I edited my question. – user16307 Mar 2 '16 at 10:36

If your data is uniformly sampled, which it looks like it is, I would personally use the function in LTspice to read WAVE files.

To use it, add a voltage source to your circuit and as the voltage expression you enter:

wavefile="C:\path\to\your\file.wav" chan=0


This will reproduce the sampled signal efficiently with minimum storage space.

• not wave file mine are txt files – user16307 Mar 2 '16 at 12:45
• @user16307, then you can translate your data into a wav file. You should be able to do this in Matlab or whatever programming language you like, with a little research on the WAV format. – The Photon Mar 2 '16 at 17:09
• why would i convert to wav if LTspice can already read txt? – user16307 Mar 2 '16 at 17:26
• wav files (may) use less disk space, this could be a game changer for complicated signals. – Jasen Mar 4 '16 at 0:02
• @user16307 Because you used the expression write them to a text file, I assumed that you had the data in some kind of raw, non-text format, and to make a text file you had to convert it anyway. If the dataset is tiny, and already in a file format that PWL can read, there's no need to convert it. – pipe Mar 4 '16 at 3:21