From: Muhammad on
Hello,

Assume that I have a subspace like:

span{1 5 10
0 6 11
1 7 12}

In Matlab, how can I check if a given vector is in the subspace or not? Like v=[1;2;3]

Thanks
From: Matt J on
"Muhammad " <inan.5(a)buckeyemail.osu.edu> wrote in message <hj2n7o$mou$1(a)fred.mathworks.com>...
> Hello,
>
> Assume that I have a subspace like:
>
> span{1 5 10
> 0 6 11
> 1 7 12}
>
> In Matlab, how can I check if a given vector is in the subspace or not? Like v=[1;2;3]

Span of the rows or the columns.
If the columns, then here's one way


>> A=[1 2 3; 4 5 6; 7 8 9]', v=[1;2;3]

A =

1 4 7
2 5 8
3 6 9


v =

1
2
3

>> Z=orth(A);
>> v-Z*(Z\v); %should be close to 0 if v is in the column space of A

ans =

1.0e-015 *

-0.2220
0
0
From: Muhammad on
Thank you very much. It really helped me a lot. This is very straight and practical approach.

Thanks again.

> Span of the rows or the columns.
> If the columns, then here's one way
>
>
> >> A=[1 2 3; 4 5 6; 7 8 9]', v=[1;2;3]
>
> A =
>
> 1 4 7
> 2 5 8
> 3 6 9
>
>
> v =
>
> 1
> 2
> 3
>
> >> Z=orth(A);
> >> v-Z*(Z\v); %should be close to 0 if v is in the column space of A
>
> ans =
>
> 1.0e-015 *
>
> -0.2220
> 0
> 0