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 で Symbolic Math Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!