Info

This question is closed. Reopen it to edit or answer.

hi. I want to draw the 3D PLOT of this but i can only draw 2-D. kindly help. I am new.

1 view (last 30 days)
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 Comments
Walter Roberson
Walter Roberson on 30 Aug 2020
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.
rana zain
rana zain on 30 Aug 2020
the value of y is y= 40*sin(pi*x) as given in the problem. i still attached my whole question in pdf form.

Answers (0)

This question is closed.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!