필터 지우기
필터 지우기

Solving a vector system

조회 수: 5 (최근 30일)
Robert
Robert 2015년 2월 6일
답변: Ceasar_Ullrich9 2020년 1월 25일
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

답변 (4개)

Ceasar_Ullrich9
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

James Tursa
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
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.
Robert
Robert 2015년 2월 6일
James, Thank you. I follow what your saying now.
Your going about it with elimination of course which makes perfect sense. I guess I'm trying to hard to understand the matlab part and not thinking outside of matlab
I can solve it now of course just using elimination. Let me ask you this though. Is there a way for matlab to do it for you? Say i come across a matrix that is not so easy and does not eliminate easily. How can i put these values into a matrix of some sort and ask matlab to solve it? Does it have that ability?

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


Robert
Robert 2015년 2월 6일
편집: Robert 2015년 2월 6일
Im not sure i am following you. I can surly sit here and do it all out with the components. This would yield 6 questions and 6 unknowns.
So how do i get matlab to do it in one swoop for me?

Robert
Robert 2015년 2월 6일
I do understand your desire to help me to learn something instead of just giving me the answer. However could you be more explicit. I have never used matlab before.

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by