필터 지우기
필터 지우기

help with curve fitting

조회 수: 1 (최근 30일)
random1072
random1072 2020년 5월 4일
편집: Ameer Hamza 2020년 5월 4일
trying to fit the curve on my graph so that it is rounded not sharp. Thank you.
figure(2);
plot(q_0,'ko-','Linewidth',1.5)
hold on
plot(q_1,'rs-','Linewidth',1.5)
plot(q_2,'bd-','Linewidth',1.5)
plot(q_3,'gv-','Linewidth',1.5)
hold off
xlim([1 13])
fit
legend({'Q0','Q1','Q2','Q3'})

채택된 답변

Ameer Hamza
Ameer Hamza 2020년 5월 4일
편집: Ameer Hamza 2020년 5월 4일
If you don't have an equation of your dataset, then it will be simpler to use the following methods
spline()
rng(0)
x = 1:10; % x-values
y = rand(size(x)); % random y-values
xv = linspace(min(x), max(x), 100); % more points on x-axis to make a smooth curve
yv = spline(x, y, xv); % interpolation using spline
plot(x, y, 'ro-', xv, yv, 'b-')
pchip()
rng(0)
x = 1:10; % x-values
y = rand(size(x)); % random y-values
xv = linspace(min(x), max(x), 100); % more points on x-axis to make a smooth curve
yv = pchip(x, y, xv); % interpolation using pchip
plot(x, y, 'ro-', xv, yv, 'b-')
makima()
rng(0)
x = 1:10; % x-values
y = rand(size(x)); % random y-values
xv = linspace(min(x), max(x), 100); % more points on x-axis to make a smooth curve
yv = makima(x, y, xv); % interpolation using makima
plot(x, y, 'ro-', xv, yv, 'b-')

추가 답변 (1개)

David Hill
David Hill 2020년 5월 4일
Use fit() function

카테고리

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

제품

Community Treasure Hunt

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

Start Hunting!

Translated by