File Exchange

image thumbnail

subspace.m

version 1.1 (2.66 KB) by Andrew Knyazev
Angle between subspaces.

7 Downloads

Updated 15 May 2015

View Version History

View License

SUBSPACE(A,B) finds the largest angle between two subspaces specified by the columns of A and B. If A and B are vectors of unit length, this is the same as COS(ABS(A'*B)) in exact arithmetic. This is a replacement for MATLAB's SUBSPACE.m Rev. 5.5-5.8 that fails to provide correct answers for angles smaller than e-8 and for Rev. 5.9-5.10.4.3 that fails to provide correct answers for angles close to pi/2.

Cite As

Andrew Knyazev (2021). subspace.m (https://www.mathworks.com/matlabcentral/fileexchange/54-subspace-m), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (10)

jyoti mundra

Thanks a lot.

Andrew Knyazev

The provided function SUBSPACE(A,B) has the exactly same functionality as MATLAB's SUBSPACE.m, i.e. computes the LARGEST angle only, but computes it accurately in the whole range of values from 0 to pi/2, in contrast to MATLAB's SUBSPACE.m.

To compute ALL angles accurately, as well as the corresponding principal vectors, use SUBSPACEA(A,B) from https://www.mathworks.com/matlabcentral/fileexchange/55-subspacea-m

jyoti mundra

No, this is completely fine. I was expecting other than the largest angles. But that part is included in "subspacea.m" which is great work.

Andrew Knyazev

In https://www.mathworks.com/matlabcentral/fileexchange/55-subspacea-m,
"If A is not provided as a third argument, than A=I and the function gives the same largest angle as SUBSPACE.m"

Re: jyoti mundra, why 4 stars? Anything wrong that needs to be fixed or improved?

jyoti mundra

jyoti mundra

Thanks alot for your prompt response.
Actually I have check that link before, But I was not sure how do we decide matrix A in that case.

Andrew Knyazev

Re: jyoti mundra, thanks for your kind words!
Please see https://www.mathworks.com/matlabcentral/fileexchange/55-subspacea-m

jyoti mundra

Great work.
How can we get other than largest angles from this code?

Elmi bin

Ma Chaojie

Good

MATLAB Release Compatibility
Created with R14SP1
Compatible with any release
Platform Compatibility
Windows macOS Linux
Tags Add Tags
Acknowledgements

Inspired by: subspacea.m

Inspired: subspacea.m

Community Treasure Hunt

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

Start Hunting!