Symbolic Substitution Using a Struct

조회 수: 3 (최근 30일)
Kevin Bachovchin
Kevin Bachovchin 2013년 5월 28일
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

채택된 답변

Walter Roberson
Walter Roberson 2013년 5월 28일
subs(MyExpression, fieldnames(MyStruct), struct2cell(MyStruct))

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Structures에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by