Effacer les filtres
Effacer les filtres

Symbolic Substitution Using a Struct

4 vues (au cours des 30 derniers jours)
Kevin Bachovchin
Kevin Bachovchin le 28 Mai 2013
Hello,
I have a Nx1 matrix of symbolic variables called XReplace. In a symbolic expression called MyExpression, I would like to replace XReplace with the symbolic values in a struct called MyStruct, which has N fields each of which contain a symbolic expression I wish to substitute in. Using NewExpression = subs(MyExpression,XReplace,MyStruct) doesn't work since XReplace is a matrix while MyStruct is a struct. Is there anyway I can do this substitution without using a for loop to iterate through each field of the struct?
Thank you,
Kevin

Réponse acceptée

Walter Roberson
Walter Roberson le 28 Mai 2013
subs(MyExpression, fieldnames(MyStruct), struct2cell(MyStruct))

Plus de réponses (0)

Catégories

En savoir plus sur Symbolic Math Toolbox dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by