I have a symbolic matrix that has equation in it.
I want to extract the equations.
I have the code from the inside nodes.
B =
[50, 100, 100, 200]
[50, T23 - 4*T22 + T32 + 150, T22 - 4*T23 + T33 + 300, 200]
[50, T22 - 4*T32 + T33 + 350, T23 + T32 - 4*T33 + 500, 200]
[50, 300, 300, 200]
for i=2:n;
for j=2:m;
eq(i,j)=B(i,j)
end
end
But this doesnt work
I would like my answer to be
eq(2,2)=B(2,2)
eq(2,3)=B(2,3)

댓글 수: 4

Snicklefrits
Snicklefrits 2021년 11월 2일
or equation22=B(2,2)
Matt J
Matt J 2021년 11월 2일
편집: Matt J 2021년 11월 2일
What should eq(i,1) and eq(1,j) be? Why not just set eq=B if eq and B are pretty much the same.
Snicklefrits
Snicklefrits 2021년 11월 2일
I want them to be individual equation to use the solve function. Is there any easier method to solve for the symbolic functions inside the matrix?
Snicklefrits
Snicklefrits 2021년 11월 2일
I would want eq(2,1) to equal the equation of B(2,1) so I can use Solve(eq,T1 T2 T3 T4)

댓글을 달려면 로그인하십시오.

 채택된 답변

Matt J
Matt J 2021년 11월 2일
편집: Matt J 2021년 11월 2일

0 개 추천

syms B eq T23 T22 T32 T33
B =[50, 100, 100, 200;
50, T23 - 4*T22 + T32 + 150, T22 - 4*T23 + T33 + 300, 200;
50, T22 - 4*T32 + T33 + 350, T23 + T32 - 4*T33 + 500, 200;
50, 300, 300, 200];
[n,m]=size(B);
eq(2:n,2:m)=B(2:end,2:end)
eq = 
eq(2,2)
ans = 

댓글 수: 4

Snicklefrits
Snicklefrits 2021년 11월 2일
When i run this I get
eq =
[0, 0, 0]
[0, T23 - 4*T22 + T32 + 150, T22 - 4*T23 + T33 + 300]
[0, T22 - 4*T32 + T33 + 350, T23 + T32 - 4*T33 + 500]
Snicklefrits
Snicklefrits 2021년 11월 2일
Ill post my whole code
Matt J
Matt J 2021년 11월 2일
Well, I already showed you what I get.
Snicklefrits
Snicklefrits 2021년 11월 2일
What if i wanted to list all of the those values ie (B22,B23,B32,B33) like I just type with commas in between them So I can use
eqns = [B(2,2),B(2,3),B(3,2),B(3,3)
]
[A,b] = equationsToMatrix(eqns)
Y = inv(A)
Y*b
This code works. Thanks for you suggestion of just using the B matrix but I just need a way to call these values and seperate them by comas so I can use inverse matrix to solve it.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2021년 11월 2일

0 개 추천

Here is the corrected code:
clearvars
syms T22 T32 T33 T23
%% Note how your equations are set up
B =[50, 100, 100, 200;
50, T23 - 4*T22 + T32 + 150, T22 - 4*T23 + T33 + 300, 200;
50, T22 - 4*T32 + T33 + 350, T23 + T32 - 4*T33 + 500, 200;
50, 300, 300, 200];
for ii = 1:4
for jj=1:4
EQN(ii,jj)=B(ii,jj)
end
end
% Test
EQN(2,2)
EQN(3,2)

카테고리

도움말 센터File Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기

제품

태그

질문:

2021년 11월 2일

댓글:

2021년 11월 2일

Community Treasure Hunt

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

Start Hunting!

Translated by