Hi,
I understand that you are trying to obtain an approximation to a n-dimensional vector v, in a k-dimensional subspace (spanned by a k-subset of the n basis vectors of v).
Different k-subsets of the basis B’ may span different subspaces. For e.g., for k = 2, the subspace spanned by (b1’, b2’) may not be the subspace spanned by (b3’, b4’).
For very small values of n and k, the following approach would work:
1. Take a k-combination of basis vectors in B’, call it A. Let W = Col(A)
2. Calculate the orthogonal projection of v w.r.t W using the following theorem
Here, xw is the said orthogonal projection. (vw in your case)
3. ||v-vw|| will give the “distance” or “error” of the projection.
4. Repeat the steps for all k-combinations of B’. Choose the combination with the least error.
However, this approach does not scale well with increasing values of n and k.
If your goal is reducing the dimensionality of B’, you may use PCA (or SVD) instead. PCA (Principal Component Analysis) can be used to reduce dimensional representation of data, with the smallest reconstruction error.
The “pca” function in the Statistics and Machine Learning Toolbox can be used to achieve the same.
In MATLAB coeff = “pca(X)” returns the principal component coefficients for the n-by-p data matrix X. Each column of “coeff” contains coefficients for one principal component, and the columns are in descending order of component variance. By default, “pca” centers the data and uses the singular value decomposition (SVD) algorithm.
Please refer to the following code:
coeff = pca(ingredients, "NumComponents", 4);
Please refer to the following documentations for further reference:
Hope this helps!
Best Regards,
Saarthak