jin law
2018-10-11 09:24:38 UTC
Greeting! First of all I like to apologize for the inconvenience cause. It is very tricky to use Octave I find
it too. Even I copy and paste, I still get error. Until I tried it for few times, I am sorry for the trouble.
Data =
1874 1092 2510 1624
1895 1323 2611 1097
3202 2683 2346 1522
data =
1837 1372 2114 1097
2788 1052 2099 1725
2567 1217 2878 1195
y=Data(:,j);
X=[ones(3,1),data(:,j)];
theta(:,j)=round(pinv(X'*X)*X'*y);
Theta=theta(1,1:j);
end
error: A(I,J,...) = X: dimensions mismatch
For the second part, what I want to do is y1 and [X1,X2,X3,X4] then y2 and [X1,X2,X3,X4] and so on til y4.
It means:
for j=1:4;
y=Data(:,1);
X=[ones(3,1),data(:,j)];
theta(:,j)=round(pinv(X'*X)*X'*y);
Theta=theta(1,1:j);
end
do it four times, so I used nested loop;
y=Data(:,2);
X=[ones(3,1),data(:,j)];
theta(:,j)=round(pinv(X'*X)*X'*y);
Theta=theta(1,1:j);
end
error: A(I,J,...) = X: dimensions mismatch
X=[ones(3,1),data(:,j)];
end
X =
1 1097
1 1725
1 1195
Without semi colon after X , the results I get is different.
X=[ones(3,1),data(:,j)]
end
X =
1 1837
1 2788
1 2567
X =
1 1372
1 1052
1 1217
X =
1 2114
1 2099
1 2878
X =
1 1097
1 1725
1 1195
y=Data(:,2)
X=[ones(3,1),data(:,j)]
theta(:,j)=round(pinv(X'*X)*X'*y);
end
y =
1092
1323
2683
X =
1 1837
1 2788
1 2567
error: A(I,J,...) = X: dimensions mismatch
This is the tricky part I find!
for j=1:4;
X=[ones(3,1),data(:,j)];
theta(:,j,j)=round(pinv(X'*X)*X'*y);
Theta=theta(1,1:j,1:j);
end
end
error: A(I,J,...) = X: dimensions mismatch
Every part I copy and paste I can't get the answer i want.
This is the trouble I faced.
Thanks,
Jin
Sent from Mail for Windows 10
it too. Even I copy and paste, I still get error. Until I tried it for few times, I am sorry for the trouble.
Data=[ 1874,1092,2510,1624; 1895,1323, 2611,1097; 3202,2683,2346,1522]
1874 1092 2510 1624
1895 1323 2611 1097
3202 2683 2346 1522
data=[ 1837 1372 2114 1097; 2788 1052 2099 1725; 2567 1217 2878 1195]
1837 1372 2114 1097
2788 1052 2099 1725
2567 1217 2878 1195
for j=1:4;
X=[ones(3,1),data(:,j)];
theta(:,j)=round(pinv(X'*X)*X'*y);
Theta=theta(1,1:j);
end
error: A(I,J,...) = X: dimensions mismatch
For the second part, what I want to do is y1 and [X1,X2,X3,X4] then y2 and [X1,X2,X3,X4] and so on til y4.
It means:
for j=1:4;
y=Data(:,1);
X=[ones(3,1),data(:,j)];
theta(:,j)=round(pinv(X'*X)*X'*y);
Theta=theta(1,1:j);
end
do it four times, so I used nested loop;
for j=1:4;
X=[ones(3,1),data(:,j)];
theta(:,j)=round(pinv(X'*X)*X'*y);
Theta=theta(1,1:j);
end
error: A(I,J,...) = X: dimensions mismatch
for j=1:4;
end
X
1 1097
1 1725
1 1195
Without semi colon after X , the results I get is different.
for j=1:4;
end
X =
1 1837
1 2788
1 2567
X =
1 1372
1 1052
1 1217
X =
1 2114
1 2099
1 2878
X =
1 1097
1 1725
1 1195
for j=1:4;
X=[ones(3,1),data(:,j)]
theta(:,j)=round(pinv(X'*X)*X'*y);
end
y =
1092
1323
2683
X =
1 1837
1 2788
1 2567
error: A(I,J,...) = X: dimensions mismatch
This is the tricky part I find!
for j=1:4;
y=Data(:,j);for j=1:4;
X=[ones(3,1),data(:,j)];
theta(:,j,j)=round(pinv(X'*X)*X'*y);
Theta=theta(1,1:j,1:j);
end
end
error: A(I,J,...) = X: dimensions mismatch
Every part I copy and paste I can't get the answer i want.
This is the trouble I faced.
Thanks,
Jin
Sent from Mail for Windows 10