0
\$\begingroup\$

I'm trying to export a waveform from ltspice into an excel document to be later graphed using Matlab. I am simulating a simple series bandpass filter and when I export the voltage across a capacitor. It is not simply putting the voltage values into the second column. I am only given the option to use polar or Cartesian coordinates. Then when I am parsing the data in Matlab, it is not populating the variables because the second column is being occupies by coordinates. Can I change this export format somehow??

\$\endgroup\$

2 Answers 2

1
\$\begingroup\$

Maybe this is not what OP's after (and I misunderstood?), but it looks like he needs to add .option meascplxfmt=cartesian to the LTspice schematic prior to simulation. See the help for LTspice > Dot Commands > .options and look at MEASCPLXFMT for details. It allows three keywords: bode, cartesian, polar.

\$\endgroup\$
1
  • \$\begingroup\$ This helps me when viewing LTSpice Measurement in the SPICE Error Log, I'm expecting non-decibel measurement. \$\endgroup\$
    – Unknown123
    Commented Feb 28, 2019 at 12:28
0
\$\begingroup\$

You don't need to, thats the beauty of scripting languages.

First generate a text file with Cartesian coords. Use the importer to generate a script, like this: enter image description here then add a loop to post process the text.

>> Vn002{1}

ans =

8.53289842950458e-002,-5.03255593977887e-006

This is what the first value of my array looks like, but its a cell with text, so to get it to numbers you use sscanf. (%f means you want to convert an string with floating point format to a number.)

temp = sscanf(Vn002{1},'%f,%f')
dB = temp(1);
phase = temp(2);

This is for one line, I hope your able to put this inside a loop.

\$\endgroup\$
9
  • \$\begingroup\$ How does this get me to just the voltage value? I have this in my Matlab script. % read in data from excel get frequency values freq = xlsread('data.xlsx','A2:A5002'); % 50 ohms 5000 Hz series [num1,Vn001] = xlsread('data.xlsx','B2:B5002'); y1 = zeros(5001,1); for n = 1:5001 y1(n) = sscanf(Vn001{n},'%f'); end I'm only getting the first coordinate but when I have '%f,%f' I keep getting errors and do not know how to resolve them besides doing what I have done above. \$\endgroup\$ Commented Mar 6, 2017 at 20:24
  • \$\begingroup\$ Can you convert from dB to voltage? \$ dB = 20 × log (V_{out} / V_{in}) \$ where Vin is your source \$\endgroup\$
    – Voltage Spike
    Commented Mar 6, 2017 at 20:25
  • \$\begingroup\$ I am only able to get the first coordinate into my vector, would this still apply? \$\endgroup\$ Commented Mar 6, 2017 at 20:28
  • \$\begingroup\$ Don't use excel, use the data importer in matlab under TABS: Home-> Data import \$\endgroup\$
    – Voltage Spike
    Commented Mar 6, 2017 at 20:32
  • \$\begingroup\$ I figured it out, thanks for your help though. \$\endgroup\$ Commented Mar 6, 2017 at 20:44

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.