Home > OS >  MATLAB: linear regression for data that is stored in matrices (for loop?)
MATLAB: linear regression for data that is stored in matrices (for loop?)

Time:06-14

I try to do a linear regression for data that is stored in several matrices (Matlab). For vectors, the linear regression is pretty straight forward:

%x-values
x = [1.5;2.5;5];                                        %x-vector
          
%y-values
y = [9;11.1;17];                                        %y-vector

%Regression:
X = [ones(length(x),1) x]                               %Matrix to do the backslash calculation--> how can I set that up if I have a matrix for x and not a vector?
m2 = X\y;                                                          
  • Related