필터 지우기
필터 지우기

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에서 Matrices and Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by