Plugging in matrix values into function handle of more than 1 variables
1 view (last 30 days)
Show older comments
M Al Mamun
on 6 Apr 2020
Answered: Walter Roberson
on 6 Apr 2020
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 Comments
Accepted Answer
Walter Roberson
on 6 Apr 2020
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 Comments
More Answers (0)
See Also
Categories
Find more on Symbolic Math Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!