Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7800337
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T00:36:11+00:00 2026-06-02T00:36:11+00:00

After running a SPICE simulation I get an .a2d file which I am parsing

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T00:36:13+00:00Added an answer on June 2, 2026 at 12:36 am

    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.

    % fake data
    vars = {'sums4', 'sums2', 'sums1', 'a0', 'a5'};
    data(1,:) = logical([0 0 1 0 0 0 1]);
    data(2,:) = logical([0 1 1 1 1 0 0]);
    data(3,:) = logical([1 0 1 1 0 0 1]);
    data(4,:) = logical([0 0 1 0 1 1 1]);
    data(5,:) = logical([0 1 1 1 0 0 0]);
    
    output = struct();
    for i = 1:length(vars) 
        matches = regexp(vars{i}, '(\D+)(\d+)', 'tokens');
        var = matches{1}{1};
        shiftsize = str2num(matches{1}{2});
    
        % initialise if not already present
        if (~isfield(output, var))
            output.(var) = zeros(1, size(data, 2));
        end
    
        % add apropriate shifted value to current values
        output.(var) = output.(var) + (bitshift(1, shiftsize) * data(i, :));
    end
    

    output ends up with fields named after the string parts of vars

    output = 
    
        sums: [2 4 22 6 4 0 18]
           a: [0 32 33 32 1 1 1]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

After running a model in fortran (95) I end up with some result arrays
After running the following SQL statements, you will see that, MySQL has automatically created
After running a new Play-framework 2.0 based project, i failed to clean it -
After running exec sp_lock on one of our databases we found there's close to
The following output appears after running some rake tasks: Loaded suite /usr/bin/rake Started Finished
How do you make the documentation available after running rake doc:app available within your
I am getting the following error after running git svn rebase: 'update-index --refresh: command
I recently created a ajax based instant messaging application and after running for a
I am getting an argument of length zero after running the code below. I
Can anyone tell me why I always have this strange output after running this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.