How can I get a smooth curve in MATLAB?

조회 수: 5 (최근 30일)
Itqan Ismail
Itqan Ismail 2023년 1월 31일
댓글: Star Strider 2023년 1월 31일
x=[0:30:210];
%Composition
%Outlet Specification [PFAD(4)]
y=[44.0789 62.428 77.24324 85.35 89.435 91.353 92.504 92.6252];%FFA
z=[90.4422 59.243 32.241 13.8 5.232 1.2421 0.6243 0.5465];%TAG
plot(x,y,'-b',x,z,'--r')
title('composition vs time');
xlabel('time');
ylabel('xd');
legend('a) FFA','b)TAG');

채택된 답변

Star Strider
Star Strider 2023년 1월 31일
One option is to interpolate to a finer ‘x’ vecttor, and then use a method such as 'pchip', 'spline', 'makima', or others to do a smoother interpolation.
Example —
x=[0:30:210];
%Composition
%Outlet Specification [PFAD(4)]
y=[44.0789 62.428 77.24324 85.35 89.435 91.353 92.504 92.6252];%FFA
z=[90.4422 59.243 32.241 13.8 5.232 1.2421 0.6243 0.5465];%TAG
figure
plot(x,y,'-b',x,z,'--r')
title('composition vs time');
xlabel('time');
ylabel('xd');
legend('a) FFA','b)TAG');
xv = linspace(min(x), max(x), numel(x)*10);
yv = interp1(x, y, xv,'pchip');
zv = interp1(x, z, xv,'pchip')
zv = 1×80
90.4422 87.5072 84.6033 81.7313 78.8918 76.0854 73.3127 70.5744 67.8711 65.2034 62.5720 59.9774 57.4068 54.8291 52.2552 49.6982 47.1711 44.6870 42.2591 39.9005 37.6243 35.4435 33.3713 31.4093 29.4769 27.5672 25.6940 23.8707 22.1111 20.4287
figure
plot(xv,yv,'-b',xv,zv,'--r')
title('composition vs time');
xlabel('time');
ylabel('xd');
legend('a) FFA','b)TAG');
.
  댓글 수: 2
Itqan Ismail
Itqan Ismail 2023년 1월 31일
Thank you for your response.
Star Strider
Star Strider 2023년 1월 31일
As always, my pleasure!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by