Increasing number of points in a plot without ruining the shape

조회 수: 16 (최근 30일)
Abhiraj Gupta
Abhiraj Gupta 2019년 8월 20일
답변: darova 2019년 8월 20일
How can I make this plot look like
this plot but instead of reducing points I want to increase data points in red plot to 20. Using linspace or interp1 is giving me a straight line. I want to conserve the shape of the plot and increase the number of points in the plot.

채택된 답변

darova
darova 2019년 8월 20일
Is it correct? (Not tested)
x1red = linspace(xred(1),xblue(end),20); % more points for red curve
% scaling red curve (make it as long as blue one)
Lred = xred(end) - xred(1);
Lblue= xblue(end) = xblue(1);
xred_scaled = xred(1) + (xred-xred(1))*Lblue/Lred;
y1red = interp1(x_red_scaled,yred,x1red);
plot(xblue,yblue,'b')
hold on
plot(x1red,y1red,'r')
hold off

추가 답변 (1개)

Stephen23
Stephen23 2019년 8월 20일
편집: Stephen23 2019년 8월 20일
Try using method spline or pchip and see if they do what you want:
interp1(...,'pchip')
  댓글 수: 1
Stephen23
Stephen23 2019년 8월 20일
Writing "it's not working" tells us nothing. If you want further help then please:
  • tell us if you are extrapolating the data.
  • show the exact code that you are using.
  • upload sample data in a .mat file.
  • show or explain how the expected output is different to what you get.

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

카테고리

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

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by