Effacer les filtres
Effacer les filtres

Warning: Rank deficient, rank = 1, tol = 1.324612e-01.

35 vues (au cours des 30 derniers jours)
McKenzie Peters
McKenzie Peters le 5 Déc 2019
Modifié(e) : Ridwan Alam le 5 Déc 2019
I'm trying to code a linear regression model using the following as a fuction script...
function [R,m,b] = ecregression(x,y)
x = x';
y = y';
format long
X = [ones(length(x),1) x];
b = X\y;
R = corr(x,y);
m = b(2);
b = b(1);
end
When I try and run this in my plot window with the code...
[R2, m2, b2] = ecregression(Y, season_avg2);
plot(Y, (m2.*Y)+b2, 'Color', 'k')
I get the error message...
Warning: Rank deficient, rank = 1, tol = 1.324612e-01.
> In ecregression (line 8)
In Extra_Credit (line 207)
(Line 207 is [R2, m2, b2] in the second code and line 8 is b = X\y)
How do I go about eliminating this error?
  3 commentaires
KALYAN ACHARJYA
KALYAN ACHARJYA le 5 Déc 2019
What are the values of input arguments to pass to the function?
Y and season_avg2
McKenzie Peters
McKenzie Peters le 5 Déc 2019
Y (stands for years) is a 1x68 double array where Y(1) = 1948 and Y(68) = 2015
season_avg is another 1x68 double array of various temperatures

Connectez-vous pour commenter.

Réponses (1)

Ridwan Alam
Ridwan Alam le 5 Déc 2019
Modifié(e) : Ridwan Alam le 5 Déc 2019
x = A\B solves the system of linear equations A*x = B. The matrices A and B must have the same number of rows. MATLAB® displays a warning message if A is badly scaled or nearly singular, but performs the calculation regardless.
In your case, A=X. column 1 of X is all 1's, making the rank of X = 1. That's what this warning is about. But I don't think that should prevent the calculation of b. Is it?

Catégories

En savoir plus sur Polynomials dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by