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.
0 个评论
采纳的回答
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrices and Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!