lines to curves drawing problem

조회 수: 2 (최근 30일)
Anas A.Salam
Anas A.Salam 2013년 6월 5일
hello i have a problem with drawing curve on line or by other words
what i have: points on X-axis with their values on Y-axis as show in figure
what i need to do: draw curve between each two points (i don't want to show the figure as lines but as curves)
thank you

채택된 답변

Kye Taylor
Kye Taylor 2013년 6월 5일
I assume you have the variables x and y which are vectors representing the values in the x-component and in the y-component of each point, respectively. Then, try this
% assuming x and y are your variables:
xValues = linspace(min(x),max(x));
yValues = interp1(x,y,xValues,'spline');
plot(x,y,xValues,yValues)
  댓글 수: 1
Anas A.Salam
Anas A.Salam 2013년 6월 5일
thank you so much i tried your code and change some thing in it to have what i need thank you again :)

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Mark
Mark 2013년 6월 5일
The problem is that MATLAB doesn't know what curve you want, since there is no data between the points you have. You either need more data resolution, or you can tell MATLAB to make a smooth curve by interpolating with a spline:
xNew = 0:0.1:160;
yNew = interp1(x,y,xNew,'spline');
plot(xNew,yNew)
However, remember that the smooth curve is made up by MATLAB, so it could be misleading to show smooth curves if there are not really any in reality.
  댓글 수: 1
Anas A.Salam
Anas A.Salam 2013년 6월 5일
thank you so much :) i try your answer but the result was not like what i accepted :) any way thank you so much for your help :)

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Smoothing에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by