Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

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

1 Ansicht (letzte 30 Tage)
rana zain
rana zain am 28 Aug. 2020
Geschlossen: MATLAB Answer Bot am 20 Aug. 2021
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 Kommentare
Walter Roberson
Walter Roberson am 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 am 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.

Antworten (0)

Diese Frage ist geschlossen.

Community Treasure Hunt

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

Start Hunting!

Translated by