필터 지우기
필터 지우기

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일)
rana zain
rana zain 2020년 8월 28일
마감: MATLAB Answer Bot 2021년 8월 20일
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
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.
rana zain
rana zain 2020년 8월 30일
the value of y is y= 40*sin(pi*x) as given in the problem. i still attached my whole question in pdf form.

답변 (0개)

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by