Rev | Line | |
---|
[25505] | 1 | def structtoobj(obj, S):
|
---|
| 2 | """STRUCTTOOBJ - Convert struct to obj
|
---|
| 3 |
|
---|
| 4 | NOTE: The following semantics are not Pythonic, but attempt to recreate the
|
---|
| 5 | same function from MATLAB.
|
---|
| 6 | """
|
---|
| 7 |
|
---|
| 8 | # Get object and structure fields
|
---|
| 9 | structfields = S.__dict__.keys()
|
---|
| 10 | objprops = vars(obj)
|
---|
| 11 |
|
---|
| 12 | # Recover object properties
|
---|
| 13 | for structfield in structfields:
|
---|
| 14 | if structfield in objprops:
|
---|
| 15 | fieldvalue = getattr(S, structfield)
|
---|
| 16 | setattr(obj, structfield, fieldvalue)
|
---|
| 17 |
|
---|
| 18 | return obj
|
---|
Note:
See
TracBrowser
for help on using the repository browser.