Solving a vector system
조회 수: 5 (최근 30일)
이전 댓글 표시
Sorry for asking a foolish question but looking to get some help on a simple problem
Lets say i have a vector A = [6,-8,2] and B = [4,6,12]
I now have two unknown vectors Call them S1 and S4
What i know is that
S1 +S4 = A
And
S1-S4 = B
How do i get matlab to solve this for me?
Thanks
댓글 수: 0
답변 (4개)
Ceasar_Ullrich9
2020년 1월 25일
A = [6 -8 2]
B = [ 4 6 12]
MATR = [1 1 ; 1 -1]
MATR^-1 * [A;B]
ans =
5 -1 7
1 -7 -5
basically it's just a linear system where unknowns are vectors instead of scalars
댓글 수: 0
James Tursa
2015년 2월 6일
HINT: What do you get when you add the two equations together? And what do you get when you subtract the two equations? Just do that and you can easily solve for what you want and then write the resulting formulas to m-code.
댓글 수: 2
James Tursa
2015년 2월 6일
The first part of the HINT was not really about MATLAB, it was about finding algebraic formulas to describe the answer. I will spell out the first one:
S1 + S4 = A
+ S1 - S4 = B
----------------
2*S1 = A + B
From the above you can solve for S1. Then do another calculation by subtracting the two equations instead of adding them. That will help you solve for S4. Then you can code up the expressions you got for S1 and S4 into MATLAB m-code.
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!