I'm writing a script to find the basis of subspace spanned by a vector set and by a homogenous system. In the case with the vector set, I plan to put my given matrix through rref to find the pivots and from there point out the vectors that are the bases.
Here's what I got so far
disp('input matrix')
A = input('A=')
Ar = rref(A)
s = size(Ar)
s1=s(1)
s2=s(2)
for i=1:s1
for i=1:s2
if Ar(i)== 1
A(:,i)
end
end
end

댓글 수: 2

for i=1:s1
for i=1:s2
end
Is both are "i"?
Jacked Daniel
Jacked Daniel 2019년 12월 1일
yeah but they I don't think it matters, I changed it to t and had the same results. I also used two i(s) before for two different for loops and it was fine then.

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

답변 (1개)

Matt J
Matt J 2019년 12월 1일

0 개 추천

You could just use orth()

댓글 수: 3

Jacked Daniel
Jacked Daniel 2019년 12월 3일
I read the description of the orth command, at first it seemed like the "Easy button" for me but the values it returns are not what I expected. I still can't fully understand how the orth command works and the basis it returns is completely different from what I get solving by hand.
Matt J
Matt J 2019년 12월 3일
You do realize that the basis for any linear space is non-unique, right?
Jacked Daniel
Jacked Daniel 2019년 12월 12일
Yes and are you suggesting that the ugly combination of entries I received is a basis? I do agree but I can't show that to my teacher cause she's gonna check and compare my MATLAB basis to her do-it-by-hand basis. So I can't use the orth command BUT the null command I use for the case of subspace spanned by homogenous systems is quite handy. It returns the exact value I expect it would. Oh and I figured out how to work the code, I added a "break" command and it is looking good. Thanks for helping me.

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

카테고리

도움말 센터File Exchange에서 Matrix Indexing에 대해 자세히 알아보기

질문:

2019년 12월 1일

댓글:

2019년 12월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by