• Skip to main content
  • Skip to search
  • Skip to footer
Cadence Home
  • This search text may be transcribed, used, stored, or accessed by our third-party service providers per our Cookie Policy and Privacy Policy.

  1. Community Forums
  2. Adams
  3. Delete matrix values with python

Following Cadence Design Systems’ acquisition of the Design & Engineering (D&E) business, the D&E Community Forum on the Nexus Community Center has been migrated in the Cadence Physical System Simulation Community. For more details and if you have any questions, please refer to the FAQ.

Stats

  • State Verified Answer
  • Replies 2
  • Subscribers 3
  • Views 4
  • Members are here 0
More Content

Delete matrix values with python

Todd Gatman
Todd Gatman over 1 year ago
I have a 3 column by N row matrix that is created by tracing a marker with respect to ground. I need to delete a row from this matrix with a python script. It would be nice to be able to do this to any row, but my immediate need is to remove the first row (or the first three values). I can get a reference to the matrix with no issue, but there is something I am missing in order to delete values. Any thoughts please?
 
  • Sign in to reply
  • Cancel
  • Kent West
    0 Kent West over 1 year ago
    Hi Todd,
     
    This is easy in standard Python, but the relationship between the gcurve, curve & matrix objects is a little odd when you first look at it. Here is a function that removes a row - it hasn't been tested much and it's ugly, but it works for a simple example:
    def gcurve_remove_row(curve_name, rownum):
    import Adams
    gc = Adams.stoo(curve_name)
    curve_ref = gc.ref_curve
    m = curve_ref.matrix
    if (rownum > 0) and (rownum <= m.row_count):
    data = m.values
    remove_start = (rownum - 1) * 3
    remove_end = remove_start + 2 + 1
    start_array = data[:remove_start]
    end_array = data[remove_end:]
    print('start array: ', start_array)
    print('end array: ', end_array)
    newdata = start_array + end_array
    m.modify(values=newdata, row_count=m.row_count-1, column_count=3)
    curve_ref.matrix = m # triggers update of gcurve?
     
    else:
    print('curve matrix has {} rows. Cannot remove index {}.'.format(m.row_count, rownum))
     
    gcurve_remove_row('gcurve_1', 2)
     
    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Reject Answer
    • Cancel
  • Todd Gatman
    0 Todd Gatman over 1 year ago
    Thanks Kent, that got me on the right track.
    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Cadence Guidelines

Community Guidelines

The Cadence Design Communities support Cadence users and technologists interacting to exchange ideas, news, technical information, and best practices to solve problems and get the most from Cadence technology. The community is open to everyone, and to provide the most value, we require participants to follow our Community Guidelines that facilitate a quality exchange of ideas and information. By accessing, contributing, using or downloading any materials from the site, you agree to be bound by the full Community Guidelines.

© 2026 Cadence Design Systems, Inc. All Rights Reserved.

  • Terms of Use
  • Privacy
  • Cookie Policy
  • US Trademarks
  • Do Not Sell or Share My Personal Information