How do I solve for two unknowns in this matrix?

조회 수: 2 (최근 30일)
fordxgt
fordxgt 2015년 1월 30일
댓글: antlhem 2018년 8월 29일
I've defined C and D previously and E and F are my unknowns. My code is
A = equationsToMatrix([C, D], [F, G]);
B = [ ];
X = linsolve(A,B);
result = double(X);
I know AX=B but in this case I don't know how to code B if it is to be the constants in the two equations C and D.
For example, if C = 0.011F-0.101G-0.555 and D=-0.028F-0.003G-0.055, Matrix A is [0.011, 0.101; -0.028, -0.003]. How do I get B to be [0.555; 0.055]?
Also, I'd rather not manually enter the values into B.

채택된 답변

Hikaru
Hikaru 2015년 1월 30일
This should solve your problem:
[A, B] = equationsToMatrix([C, D], [F, G])
  댓글 수: 2
fordxgt
fordxgt 2015년 1월 30일
Thanks, that did it!
antlhem
antlhem 2018년 8월 29일
guys is there any way to solve the linear equations where the variables are present in both A and B arrays? please take a look to my question with more detail: https://uk.mathworks.com/matlabcentral/answers/416689-linear-system-of-equations

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Environment and Clutter에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by