Plugging in matrix values into function handle of more than 1 variables

1 次查看(过去 30 天)
The symbolic variables and the function are given below.
x=sym('x',[1 9]);
x0=sym('x0',[1 9]);
Yr=sym('Yr',[3 3]);
Yi=sym('Yi',[3 3]);
f(1,1)=x(1)+Yr(2,2)*x0(3)+Yi(1,2)*x(4)+Yr(3,3);
f(2,1)=x(2)+Yr(1,2)*x0(2)+Yi(3,2)*x(4)+2*Yi(3,3);
Now, the I have the variable values as below.
Yr=ones(3,3); Yi=ones(3,3)+1;
x0=[1 2 3 4 5 6 7 8 9];
Now, how can I plug in the values of the elements of Yr, Yi and x0 present in the function handle f at a time while keeping the x variable as it is?
It would be highly appreciated if anybody could help me ragarding this. Thank you.

采纳的回答

Walter Roberson
Walter Roberson 2020-4-6
x=sym('x',[1 9]);
x0=sym('x0',[1 9]);
Yr=sym('Yr',[3 3]);
Yi=sym('Yi',[3 3]);
f(1,1)=x(1)+Yr(2,2)*x0(3)+Yi(1,2)*x(4)+Yr(3,3);
f(2,1)=x(2)+Yr(1,2)*x0(2)+Yi(3,2)*x(4)+2*Yi(3,3);
Yr_n=ones(3,3); Yi_n=ones(3,3)+1;
x0_n=[1 2 3 4 5 6 7 8 9];
subs(f, [Yr(:); Yi(:); x0(:)], [Yr_n(:); Yi_n(:); x0_n(:)])

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Symbolic Math Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by