i need help connecting the dots with a smooth curve for this code ive written
data=zeros(1,20)
global Z_hit
for theta1=1:2:20 Z_hit=3*((0.5*(theta1^2))-((exp(-1*theta1)+theta1-1)))-2*((0.25*(theta1^2))-2*(exp(-1*theta1/2)+theta1-1))
data(theta1)=Z_hit
plot(theta1,data(theta1),'Marker','o')
hold on
end

 채택된 답변

Mischa Kim
Mischa Kim 2014년 4월 1일
편집: Mischa Kim 2014년 4월 1일

0 개 추천

Arnav, use
global Z_hit
theta1 = 1:2:20;
data = zeros(1,numel(theta1));
for ii=1:numel(theta1)
Z_hit = 3*((0.5*(theta1(ii)^2))-((exp(-1*theta1(ii))+theta1(ii)-1)))-...
2*((0.25*(theta1(ii)^2))-2*(exp(-1*theta1(ii)/2)+theta1(ii)-1));
data(ii) = Z_hit;
end
plot(theta1,data,'o-')
Do you need Z_hit? If not, you could directly assign the value computed in the loop to data(ii).

추가 답변 (1개)

Image Analyst
Image Analyst 2014년 4월 1일
편집: Image Analyst 2014년 4월 1일

0 개 추천

Perhaps putting the data into spline will help. See attached demo below in blue text.

카테고리

도움말 센터File Exchange에서 Smoothing에 대해 자세히 알아보기

질문:

2014년 4월 1일

댓글:

2014년 4월 1일

Community Treasure Hunt

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

Start Hunting!

Translated by