Info
この質問は閉じられています。 編集または回答するには再度開いてください。
hi. I want to draw the 3D PLOT of this but i can only draw 2-D. kindly help. I am new.
1 回表示 (過去 30 日間)
古いコメントを表示
x = (0:(1/60):1); % intial data as given by problem
m = length(x);
t = zeros(1,m);
t = (0:(1/60):0.5);
t(1, 32:61) = 0;
y = 40*sin(pi*x); % function vector
theta = [1; 0.2;0.8]; %initial theta
aplha = 0.1;
lambda = 2;
X = ones(m,3);
X(:,2) = x;
X(:,3) = t;
h_theta = X*theta;
h_theta = h_theta';
% error
J = 0;
for i = 1:m
J = J + (h_theta(i)-y(i))^2;
end
J = J/(2*m) ; % error using initial theta
Reg = lambda/(2*m) * sum(theta(2:3,1));
J = J + Reg
v = pinv(X'*X)*X'*y' % calculated perms
x1 = (0:0.25:1);
t1 = (0:0.1:0.4);
for i = 1:length(x1)
pol(i) = v(1) + v(2)*x1(i) + v(3)*t1(i);
end
pol
plot3(x1,t1,pol, 'r-')
10 件のコメント
Walter Roberson
2020 年 8 月 30 日
No, no one can answer the query, not unless they happen to be taking (or giving) the same clasd this is homework for, and so can supply the missing information.
We cannot plot y because there is no equation for y in what you posted. Instead there are equations for the seemingly irrelevant f and g.
回答 (0 件)
この質問は閉じられています。
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!