After running a SPICE simulation I get an .a2d file which I am parsing with Matlab. After parsing the file I get a cell array with the names of the variables
Ex: vars = {‘s0′;’s1′;’s2′;’a0′;’a1’}
and a data matrix with the signals transitions, where each row represents the data of each signal and columns represent time. All the data is binary, i.e., it’s only 0 or 1.
What I want to do is to create an algorithm that detects “words” based on the names stored in vars. For example, s0, s1, and s2 form a 3-bit word ‘s’; a0 and a1 a 2-bit word ‘a’.
Finally, what I need is to break the data matrix into one array for each word (converting from binary to decimal).
I am doing that by hand, but I want to know if there is any way to do it by a script.
Here’s a possible solution, putting the final values into the fields of a struct. I’ve used a regexp to extract the variable names and shifts as you didn’t say how long they might be.
output ends up with fields named after the string parts of vars