Re: Some multi dimensional matrix problem

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: Some multi dimensional matrix problem

jin law

Hi! I have 2 matrix X and y with mxn dimension. I doing rowwise operations using for loop.

the answer I got is 2X1 array, I want to find the closer match between the 2 operations,which is

Theta >=theta. Because of the results of the both operations is not a single vector so I can't get the

answer. I tried to reshape, an error occur. I tried using bsxfun, I am out of my wit. Please help me.

Thanks.

 

regards,

Jin

>> for j=1:8;

y=Data(:,j);

X=[ones(m,1),data(:,j)];

theta=round(pinv(X'*X)*X'*y);

disp(theta);

end

   82

    1

   1739

      1

   2078

      1

   1845

      1

   953

     1

   1121

      1

  -210

     1

   2546

      1

>> y=Data(:,j);

>> for j=1:8;

y=Data(:,9);

X=[ones(m,1),data(:,j)];

Theta=round(pinv(X'*X)*X'*y);

disp(theta);

end

   19

    1

   1767

      1

   1926

      1

   1980

      1

   961

     1

   935

     1

  -334

     1

   2549

      1

 

>> for j=1:8;

y=Data(:,j);

X=[ones(m,1),data(:,j)];

theta=round(pinv(X'*X)*X'*y);

reshape(theta,16,1);

disp(theta);

end

error: reshape: can't reshape 2x1 array to 16x1 array

syntax error

 

>>> bsxfun(@time,pinv(X'*X)*X'*y),X,y)

                                   ^

  

 

Sent from Mail for Windows 10

 



Reply | Threaded
Open this post in threaded view
|

Re: Some multi dimensional matrix problem

Leloup
Bonjour,

I am not sure to understand what you want to do    

m = 10,n=8
Data = rand(m,n)

for j=1:8;
     y=Data(:,j);
     X=[ones(m,1),Data(:,j)]
     theta=round(pinv(X'*X)*X'*y)
end

Leloup



--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html