|
From: | jin law |
Subject: | Re:Mstrix dimesions not matched |
Date: | Wed, 10 Oct 2018 16:16:07 +0800 |
data 1874,1092,2510,1624,1895,1323 2611,1097,3202,2683,2346,1522 3939,1728,3566,2737,3116,1803 3970,1930,3685,2871,3312,2569 4455,1956,3987,2985,4009,2607 4610,1997,4034,3554,4514,2734 4845,2563,4562,4078,4593,2933 5775,3139,5127,4273,4739,4067 5930,3851,5215,4771,5461,4407 6102,4129,6176,5094,5576,5373 6376,4406,6505,5127,5849,5608 6701,4598,6734,5628,5942,6621 6934,4891,7066,6421,6939,6858 7284,4979,7729,6800,6982,7326 7441,5634,7975,7341,7870,7631 7871,6202,8071,7658,8371,7770 8248,7136,8149,8045,8650,8176 8443,7483,8236,8583,8836,8276 8828,7790,8709,8605,9519,8639 8882,9524,9166,9782,9644,9349 Data 1837,1372,2114,1097,2788,1052 2099,1725,2567,1217,2878,1195 3886,2547,2827,1729,3176,1300 4080,2670,3623,1833,3194,1626 4400,2974,4232,2386,3790,1659 4794,3111,5100,3104,4010,1675 5036,3594,5236,3503,4381,1973 5423,3702,5602,3761,4706,2072 5665,3922,6192,3988,5171,2188 5785,4468,6234,4410,5750,4312 5974,4903,6400,4578,5962,4834 6038,5238,6471,5260,5978,4898 6322,6946,6648,5715,6256,5356 7016,7186,7044,6928,7169,6267 7392,7468,7110,7002,7182,6860 7979,7818,8062,7726,8822,6911 8067,8007,8154,8283,8950,7375 9055,8201,8420,8845,8986,7382 9526,8220,8855,9195,9300,9479 9904,8247,9463,9647,9757,9497 for j=1:6; y=Data(:,j); X=[ones(20,1),data(:,j)]; theta(:,j)=round(pinv(X'*X)*X'*y); Theta=theta(1,1:j); end >> Theta Theta = -512 1051 105 -1324 205 -1106 >> for j=1:6; y=Data(:,j); for j=1:6; X=[ones(20,1),data(:,j)]; theta(:,j,j)=round(pinv(X'*X)*X'*y); Theta=theta(1,1:j,1:j); end end >> Theta Theta = ans(:,:,1) = -3562 1051 105 -1324 205 -1106 ans(:,:,2) = 0 -541 0 0 0 0 ans(:,:,3) = 0 0 -3648 0 0 0 ans(:,:,4) = 0 0 0 -2011 0 0 ans(:,:,5) = 0 0 0 0 -2469 0 ans(:,:,6) = 0 0 0 0 0 -1106 I found that the above results I got was not right, something missing in my code, please help me. Thank, Jin Sent from Mail for Windows 10 |
[Prev in Thread] | Current Thread | [Next in Thread] |