NaN output only when using three ouput for QR

I'm trying to use the canoncorr function. I removed all features with NaN values from my two input matrices. Still, I get the error
Error using canoncorr (line 86)
X must contain at least one non-constant column.
This is because the function qr in
[Q1,T11,perm1] = qr(X,0);
returns all-NaN Q1 and T11, therefore at the next line rankX is 0.
Nonetheless, I noted that if I run only [Q1,T11] = qr(X,0); or [T11] = qr(X,0); all looks ok.
Any guess on what is going on?
Thank you

1 件のコメント

Chuguang Pan
Chuguang Pan 2025 年 4 月 17 日
I guess the matrix X contains NaN

サインインしてコメントする。

回答 (1 件)

Christine Tobler
Christine Tobler 2025 年 4 月 22 日

1 投票

The 3-output syntax and the 2-output syntax of QR use different implementations, so that's likely the reason you're seeing different outcomes.
I would usually expect no NaNs in Q and T11 if X has no NaN or Inf entries - but this is possible in extreme cases, for example when the values are close to realmax, where a sum will overflow to Inf.
If you can attach a .mat file with the matrix X, I can take a closer look.

カテゴリ

製品

リリース

R2024b

質問済み:

2025 年 4 月 17 日

回答済み:

2025 年 4 月 22 日

Community Treasure Hunt

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

Start Hunting!

Translated by