peterfeicht / ltspice2matlab Goto Github PK
View Code? Open in Web Editor NEWLTspice2Matlab - Import LTspice data into MATLAB
License: BSD 2-Clause "Simplified" License
LTspice2Matlab - Import LTspice data into MATLAB
License: BSD 2-Clause "Simplified" License
For a binary DC Sweep (.dc) simulation from LTspice XVII, steps are not recognized properly.
The text import uses different logic than the binary import for recognizing steps in Transient Analysis (.tran) and DC Sweep (.dc), maybe I forgot to make a change to both. I think the text logic should work for binary too, at least in the DC Sweep (.dc) case.
When adding support for UTF-16 encoded LTspice XVII files I completely forgot about non-binary files, which would encode the data as UTF-16 as well. This is not supported right now and should be added.
Note: MATLAB's fopen
function doesn't support UTF-16 officially, though it has been reported to work nonetheless.
Issue seems to appear only when Pseudo Transient is used for finding the operating point, and is consistent when I use .option commands 'noopiter', 'gminsteps = 0' and 'itl6 = 0' in my simulation. The function is consistently getting stuck in the loop around line 502 and does not leave it even after few hours (as I left it running overnight).
Recent updated function has unidentified variable or function "tolower"
Actually it should be "lower"
The attached .raw file contains four steps of a DC Sweep (.dc) simulation from two separate .step commands. The number of data points is not divisible by 4, because in some of the steps the last source value is missing.
I have no idea why LTspice would save the data this way, but we should try to handle this case nonetheless. I also don't know whether this can occur for Transient (.tran) simulations, but the handling is the same in any case.
Hello,
I am able to load the .raw file when I run a basic .tran command. However, when I include a .step directive in the simulation I get the following error from MATLAB:
Error using reshape
Size arguments must be real integers.
Error in LTspice2Matlab (line 531)
raw_data.variable_mat = reshape(raw_data.variable_mat, mat_size(1), mat_size(2) / num_steps, num_steps);
Error in test (line 6)
sr = LTspice2Matlab(path);
Any help would be greatley appreciated.
Thank You,
Ethan
Currently the "double" flag is not recognized. This flag signifies that all data is double precision (The LTspice default is that for .TRAN time is float64 and all other data is float32). This format can occur when numdgt is set above 8, however, it also is seen for NGSPICE raw files.
I've added a diff that recognizes 'double'. (Note that there can be problems when the data is not from a .TRAN simulation.)
The same diff also shows a modification for when selected_vars is a string when calling LTspice2Matlab. In that case the program directly returns the data for the indicated trace. The old behavior is that selected_vars returns the index needed to retrieve the data for the trace but not the data itself. Currently it only works for one trace.
I attached the modified MATLAB file just for convenience.
-marcel
lt2m.txt
LTspice2Matlab.txt
Hello, I am moving from MATLAB to Octave and I would like to know please how can I use this same script but in Octave without it having to crash because the MTLAB function 'contains' is not defined in Octave?
Thanks in advance.
Wallflower
Gentlemen,
after update to the original code of ltspice2matlab it stopped working in Octave 4.0.0.
I fixed it on my local PC, I had to revert to the old-fashioned style of string look-up.
Also newline constant has not been recognized by Octave. I would like to send you the updated code for tests.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.