Can a MATLAB function edit the input?
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Lorcan O'Connor
il 19 Ago 2021
Commentato: Steve Eddins
il 19 Ago 2021
In Python, I could define, say, a linked list via the class 'node' with attribute 'next', then define a recursive function
def addtoend(root, newnode):
if root.next == None:
root.next = newnode
else: addtoend(root.next,newnode)
I can't figure out how do implement this in MATLAB - I can define the class 'node' but MATLAB doesn't seem to allow functions to modify the input and keep it in the workspace. Is there any way around this?
0 Commenti
Risposta accettata
Steve Eddins
il 19 Ago 2021
You'll need your class to subclass handle. See the documentation page "Implementing Linked Lists with Classes" for details.
2 Commenti
Steve Eddins
il 19 Ago 2021
There are many benefits to the normal MATLAB function-calling behavior in which functions do not modify their inputs. I'll leave it up to you to assess the balance of pros and cons for your own work. :-)
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Call Python from MATLAB in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!